Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TutsPlus.com:
Get Started With CRUD Operations in PHP MySQL Databases
Dec 07, 2018 @ 16:53:06

On the TutsPlus.com site they've posted a tutorial for those new to PHP and MySQL out there sharing the basics of CRUD operations using the built-in language functionality ("CRUD" stands for "Create, Read, Update, Delete").

In this article, we're going to explore how you could use a MySQL database to perform CRUD (create, read, update, and delete) operations with PHP. If you want to get your hands dirty with database connectivity in PHP, this article is a great starting point.

If you are just getting started with PHP, you probably realize that database connectivity is an essential feature that you'll need to get familiar with sooner or later. In most cases, a database is the backbone of any web application and holds the data of the application. So, as a PHP developer, you'll need to know how to deal with database operations.

In this article, we'll keep things simple and explore how to use the core mysqli functions. In upcoming articles of this series, we'll explore a couple of other ways to handle database connectivity.

They then walk you through some of the basics of:

  • creating the connection to the database
  • selecting information from the database
  • inserting and updating records
  • how to pull the record information
  • deleting records from the database tables

Each item on the list comes with plenty of explanation and example code to get you on the right path to learn these basic concepts.

tagged: crud operation tutorial mysql beginner create read update delete

Link: https://code.tutsplus.com/tutorials/how-to-work-with-mysql-in-php--cms-32222

TutsPlus.com:
Object-Oriented PHP With Classes and Objects
Dec 04, 2018 @ 19:07:40

On the TutsPlus.com site, they've posted a tutorial for those wanting to get started with object-oriented programming (OOP) in PHP. In this introductory article they cover the basics of objects, classes and several over OOP-related topics.

In this article, we're going to explore the basics of object-oriented programming in PHP. We'll start with an introduction to classes and objects, and we'll discuss a couple of advanced concepts like inheritance and polymorphism in the latter half of this article.

The tutorial starts with the basics, explaining some of the key terms involved in OOP and how they can be manipulated. From there they include code examples of classes, making instances of them as objects and accessing properties and methods. With those basics out of the way, they move on to more advanced topics: encapsulation, inheritance and the basics of polymorphism.

tagged: oop objectoriented programming tutorial beginner class object

Link: https://code.tutsplus.com/tutorials/basics-of-object-oriented-programming-in-php--cms-31910

TutsPlus.com:
Write to Files and Read Files With PHP
Nov 15, 2018 @ 16:41:04

TutsPlus.com has continued their series of posts covering some of the basics of the PHP language with their latest article. In this newest tutorial they cover reading from and writing to files using functionality already included with the language.

In this tutorial, you'll learn several important functions in PHP which are sufficient for all your basic file reading and writing needs. You'll learn how to read a file, write to a file, write to a text file, and check if a file exists.

Luckily, PHP provides a lot of functions to read and write data to files. In this tutorial, I'll show you the easiest ways to read data from a local or remote file and how to use flags to write to files exactly how we want.

The tutorial is broken down into several sections:

  • checking if a file exists
  • reading data from a file
  • writing data to a file
  • reading and writing data to files

Each section comes with a bit of description and code examples showing it in action. The post wraps up with some final thoughts and "gotchas" that you need to know when working with files in PHP (especially large ones).

tagged: tutorial introduction file read write beginner

Link: https://code.tutsplus.com/tutorials/reading-and-writing-data-to-files-in-php--cms-32117

TutsPlus.com:
PHP Control Structures and Loops: if, else, for, foreach, while and More
Oct 15, 2018 @ 17:42:13

On the TutsPlus.com site today they're "getting back to basics" with a tutorial targeted at those just learning the PHP language. In this latest tutorial, they focus on control structures and loops such as if, else, for, foreach, while and more.

In simple terms, a control structure allows you to control the flow of code execution in your application. Generally, a program is executed sequentially, line by line, and a control structure allows you to alter that flow, usually depending on certain conditions.

Control structures are core features of the PHP language that allow your script to respond differently to different inputs or situations. This could allow your script to give different responses based on user input, file contents, or some other data.

They start with a flowchart showing the basic idea behind how flow control structures work and provide a more "real world" example of a user login. It then goes through each of the control structure types, providing a simple explanation of what it does, where it's useful and code examples of it in action.

tagged: control structure language tutorial beginner

Link: https://code.tutsplus.com/tutorials/php-control-structures-and-loops--cms-31999

Sameer Borate:
Creating custom stream filters in PHP
Apr 11, 2018 @ 14:45:43

Sameer Borate has a new post to his site showing you how to create custom stream filters for use with the streams functionality already included in the PHP language. The streams handling provides a resource instance (filesystem, network connection, etc) that can be interacted with in a more standardized way.

In this post we will see how to create a custom stream filter. Streams, first introduced in PHP 4.3, provide an abstraction layer for file access. A number of different resources besides files – like network connections, compression protocols etc. can be regarded as “streams” of data which can be serially read and written to.

He shows how to get the current list of streams available and includes an example of one in use, the "string.strip_tags" filter. From there he shows the creation of a custom filter, one that replaces any URLs detected in a string with a string of [--URL--]. He includes the code for the filter and shows how to register it using the stream_filter_register function. He also includes an example of it in use, grabbing the contents of the BBC site and having the filter automatically applied.

tagged: custom filter tutorial beginner strip url

Link: https://www.codediesel.com/php/creating-custom-stream-filters/

Christoph Rumpel:
Content Security Policy 101
Mar 15, 2018 @ 14:52:43

In a new post to his site Christoph Rumpel shares an introduction to the use of Content Security policies to prevent client-side security issues in your applications. While his examples are more Laravel-specific, the concepts can be applied to just about any framework or home-grown solution.

As more and more services get digital these days, security has become a significant aspect of every application. Especially when it comes to third-party code, it is tough to guarantee safety. But in general, XSS and Code Injection is a big problem these days. Content Security Policy provides another layer of security that helps to detect and protect different attacks. Today, I will introduce this concept and its main features, as well as show real-world examples.

He starts with a general look at web application security vulnerabilities and, more specifically, cross-site scripting issues. These are the ones that a Content Security Policy (CSP) can help prevent. He then covers the basics of the CSP header and gets into the implementation. In his example he sets up the addition of the CSP header as a middleware so that it's included on every request. With the default header all resources are blocked so he walks through the process of restoring access to the scripts, fonts and styles his blog needs to work correctly.

With the basics covered he then gets into a few more advanced features of CSP policies such as nonces for resource identification, iframe handling and the submission of forms. The post ends with a recommendation of the Laravel CSP package for use in Laravel applications. If you're looking for something more framework agnostic you might want to look into ParagonIE's CSP Builder library.

tagged: contentsecuritypolicy csp beginner tutorial laravel middleware framework

Link: https://christoph-rumpel.com/2018/03/content-security-policy-101

Mustafa Magdi:
Introduction to PHP Reflection API
Dec 28, 2017 @ 17:55:43

Mustafa Magdi has written up a tutorial that introduces you to PHP's Reflection API, functionality included with the language that allows for introspection of the code and some real-time modifications.

When I started PHP coding, I wasn’t aware of the power of Reflection API and the main reason is that I didn’t need it to design my simple class, module or even my package, then I started to find it in many areas playing a major role. So in this part we will introduce Reflection API.

The post is then broken down into a few sections covering the basics of the Reflection functionality, examples of it in use and some other references you can use to get more information. Code examples are included to show how to use the API to do things like:

  • get the parent class for a current class
  • get the docblock comment of a method
  • making private methods available for testing

He also links to two packages that make use of the Reflection API heavily to generate documentation and build a dependency injection container.

tagged: reflection api introduction tutorial beginner

Link: https://medium.com/@MustafaMagdi/introduction-to-php-reflection-api-4af07cc17db4

Torben Köhn:
PHP Generators – A Guide and Tutorial
Jun 22, 2016 @ 18:45:44

For those that may have heard about generators but aren't too familiar with them or what they do, Torben Köhn has posted a great introduction to them and their functionality.

In my in-depth guide about iterators I talked about what iterators are exactly and how you can use them. At the end I told you that I’ll also write one for generators. Here it is.

First off, if you don’t know what an iterator is and you’d not be able to explain to someone else what it is, you will not have much fun with this because you won’t exactly recognize the use-cases. I suggest you read my iterator-guide first. After this, don’t get scared off by some confusing words used here, I’ll try to clarify every single one.

He breaks up the rest of the post into different sections, each walking you through different aspects of generators:

  • What is a generator?
  • The yield-keyword
  • Iterating a generator
  • Yielding keys
  • Yielding in a loop
  • An infinite generator

He wraps up the post sharing some real use-cases for generators to help you understand them with a bit more practical application (including stacking them, file system handling and co-routines).

tagged: generators tutorial introduction guide beginner

Link: http://tk.talesoft.io/2016/06/06/php-generators-a-guide-and-tutorial/

Symfony Blog:
Virtual Symfony Hack Day - March 12th!
Mar 08, 2016 @ 19:41:08

On the Symfony blog they've officially announce their latest virtual Symfony Hack Day coming in March (on the 12th). This event is a concentrated effort from the project and developers to come together and solve issues over several hours.

Symfony has always been a project driven by a huge and active community. [...] Because Symfony has a predictable release schedule, we know that feature freeze for Symfony 3.1 will be at the end of this month (March). That makes the next few weeks of development really important!

That's why we've decided to organize an online hack day, and I would love if you'd join us. If you're an experienced contributor, great! If you're new, even better! This hack day will focus on teaching you how to contribute.

The event will be happening March 12th from 3pm to 8pm CET / 9am to 2pm EST and will focus around the #symfony-dev channel on the Freenode IRC network. They'll be focusing on how to get started contributing to the framework including a mini-workshop showing how to triage issues to creating a pull request.

tagged: symfony framework hackday march virtual symfonydev freenode irc beginner contribute howto

Link: http://symfony.com/blog/virtual-symfony-hack-day-march-12th

DotDev.co:
Step by Step Guide to building your first Laravel Application
Mar 07, 2016 @ 15:25:04

On the DotDev.co site they've posted a tutorial showing you how to create your first Laravel application. In their case they show how to create a simple link collection tool to help illustrate the process.

The Laravel framework has experienced exponential growth since it’s initial release in 2011. In 2015 it became the most starred PHP framework on GitHub and has risen to be the go-to framework for people all over the world. [...] My goal with this is to create a guide for those just learning the framework. It is setup to take you from the very beginning of an idea into a real deployable application.

He starts by pointing out some prerequisites you'll need (like a local PHP environment and having PHPUnit installed). He then gets into the first step in any good application, planning, and some recommendations to think about. Once the planning is done, then the real code starts. He's broken it up into a few sections to help make it easier to follow:

  • The first steps (setting up the basic Laravel application)
  • Building a list of links
  • Submitting Links

In each step he also provides examples of tests that can be written and used to ensure your application is working as expected. Templates for the link output and the submission form are also included.

tagged: laravel application introduction beginner links tutorial first

Link: https://dotdev.co/tutorials/step-by-step-guide-to-building-your-first-laravel-application/


Trending Topics: