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

Omniceps.com:
Introduction to Latte | Best PHP templating engine
Aug 17, 2017 @ 11:30:15

On the Omniceps site there's a new post introducing you to Latte, the templating component of the Nette framework that can be used independently.

A PHP templating engine is the one which gives you ability to write html for your clients efficiently using PHP variables.

However, PHP was originally built to be a templating engine, but yet it was never used primarily as a templating engine. There has been so many PHP templating engine so far in the market since PHP evolved, but none of them has made as great impression on us as Latte. Introducing you to Latte, one of the best PHP templating engine you have come across so far. Also Latte protects your web app from vulnerabilities like XSS (cross site scripting).

The tutorial starts with an example comparing "plain old PHP" templating with the Latte version for a foreach loop. Next they show how to install the Latte component and the two different kinds of macros the tool includes. They also talk about filters, performance concerns, context aware escaping and "pretty output" options.

tagged: nette framework template component latte introduction tutorial

Link: http://www.omniceps.com/latte-best-php-templating-engine/

SitePoint PHP Blog:
Twig – the Most Popular Stand-Alone PHP Template Engine
Aug 09, 2017 @ 09:17:09

On the SitePoint PHP blog they've posted a tutorial highlighting one of the most widely used templating tools in the PHP ecosystem (that's not locked into a framework) - Twig. In this new tutorial author Claudio Ribeiro introduces you to the tool and what it has to offer you and your application.

Twig is a template engine for PHP. But isn’t PHP itself a template engine? Yes and no!

Even though PHP started as a template engine, it didn’t evolve like one [...]. PHP is a verbose language, and that verbosity is amplified when trying to output HTML content.

Modern template systems will take away some of that verbosity and still add a fair share of functionality on top. Things like security and debug features are mainstays in modern template engines.

Today, we’re focusing on Twig.

He starts off by helping you get the tool installed via Composer and shows it in use to display the values in a hard-coded PHP array. The template (index.html) outputs the result as HTML and shows the use of normal variable output, control structures and filters on the data during output. He then moves on to other topics like working with layouts, caching output, looping, conditionals and filters. The final note is about debugging, mentioning the "dump" function to directly output a value for examination regardless of type.

tagged: twig tutorial introduction template engine

Link: https://www.sitepoint.com/twig-popular-stand-alone-php-template-engine/

SitePoint PHP Blog:
Introducing the Neo4j Symfony Bundle
Aug 07, 2017 @ 13:25:34

On the SitePoint PHP blog they've posted a tutorial from author Tobias Nyholm introducing the Neo4j bundle for Symfony-based application. This bundle provides functionality to work with Neo4j graph databases natively in the application.

There is no such thing as disconnected information, no matter where you look – people, events, places, things, documents, applications and the information about them is all heavily connected. As the volume of data grows, so does the number and dynamicity of its connections. And if you’ve tried in the past to store and query that highly connected, semi-structured data in any database, you probably experienced a lot of challenges.

The tutorial talks some about graph databases, how they work and what kind of data fits into them best. It also briefly covers the Cypher Query Language followed by an introduction to the bundle and what it has to offer. Code examples of putting the bundle to use for queries are provided including the models to handle the results, relationships and an example application you can use to start with a working example.

tagged: tutorial bundle symfony introduction neo4j database

Link: https://www.sitepoint.com/introducing-the-neo4j-symfony-bundle/

Delicious Brains Blog:
How to Use Xdebug for Advanced PHP Debugging
Aug 07, 2017 @ 10:17:14

On the Delicious Brains site there's a tutorial posted that shows you how to use XDebug for advanced PHP debugging versus some of the usual practices of var_dump or print_r-ing your way through your testing.

You could just debug your PHP code using functions such as error_log, print, and var_dump, (and to be honest we’ve all done it, a lot!), but sometimes they just aren’t enough, and can actually slow you down while developing.

There must be a better way, surely?! Enter Xdebug, the rather awesome debugging and profiling tool for PHP.

In this post, I’ll take you through why Xdebug is amazing, getting it setup, how to use it, get the most out of it it, and some neat advanced uses all to make your life easier.

He starts with some background on his previous debugging practices and how discovering XDebug revolutionized his workflow. He then talks about breakpoints for debugging and what he calls "debug driven development". The article then walks you through the installation process and the integration with IDEs, specifically PHPStorm. The rest of the post shows examples of how to use XDebug along with breakpoints and IDE features to get more information about the current application state and where things are failing. He also includes sections about using XDebug for profiling and performing remote debugging via an SSH tunnel.

tagged: xdebug introduction debugging profiling tutorial setup ide integration

Link: https://deliciousbrains.com/xdebug-advanced-php-debugging/

Laravel News:
Track Laravel Model Changes with Laravel Auditing
Aug 04, 2017 @ 09:57:35

On the Laravel News site there's a post sharing a helpful package that can provide an audit trail for model changes, helping you automatically keep track of what changed when.

Laravel Auditing is a Laravel package that aims to make it easy to track eloquent model changes. The documentation describes Laravel Auditing as follows:

"This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could indicate business concerns or suspect activities.

Laravel Auditing allows you to keep a history of model changes by simply using a trait. Retrieving the audited data is straightforward, making it possible to display it in various ways."

The post talks about another use case for the package - handling versioning for records (like auto-saving a blog post periodically). An example is included showing how to implement the package on the model, show an audit history and a Blade view to show the results.

tagged: laravel model audit package introduction version

Link: https://laravel-news.com/laravel-auditing-package

CloudWays Blog:
Speed Up PHP Application Deployments Via Laravel’s Envoyer
Aug 01, 2017 @ 11:49:42

The Cloudways blog has a new tutorial posted showing you how to speed up your deployment using Envoyer, a service from the Laravel ecosystem that's used to push code to an environment in an automated way.

Envoyer is a deployment tool used to deploy PHP applications. The best thing about the the tool is the zero downtime during deployment. This means that your application and the customers using it are not even aware of the fact that a new version has been pushed.

Envoyer works well with major repository management platforms such as GitLab and Bitbucket. Other benefits include unlimited deployments and team members. The following blog will guide you through the process of deploying applications on Cloudways using Envoyer.

The tutorial then walks you through creating an Envoyer account, connect it to a repository and set up the server to deploy the code to. They then show how to set up the deployment itself, make the push to the server and configure any post-deployment steps that may need to be performed. Screenshots are included in each step of the process so you can be sure you're on the right path.

tagged: laravel envoyer deployment tutorial introduction process configuration server

Link: https://www.cloudways.com/blog/php-laravel-envoyer-deployment/

SitePoint PHP Blog:
Re-Introducing PHPUnit – Getting Started with TDD in PHP
Aug 01, 2017 @ 10:16:02

The SitePoint PHP blog has posted a tutorial that re-introduces PHPUnit and TDD (Test-Driven Development) showing you how to get started with this pre-code testing process if you want to integrate it into your development.

There are a lot of PHPUnit posts on our site already (just check the tag), but it’s been a while since we’ve actually introduced people to it, and the tool has evolved significantly since then.

This article aims to re-introduce the tool in a modern way, to a modern audience, in a modern PHP environment – if you’re unfamiliar with PHPUnit or testing, this post is for you.

They assume you're already familiar with PHPUnit and have an environment already set up with PHP and PHPUnit. They start by briefly introducing Test-Driven Development and the PHPUnit for those not overly familiar with the basics. They then bootstrap a sample application using the PDS-Skeleton project. The tutorial then walks you through the setup of the testing environment, Composer configuration and the creation of your first test. With all of that in place they start in with some failing tests (remember, TDD is "test first") and then writing the code to make it pass. They add more tests and use a data provider to set up different cases and run them all through the same test. The post then looks at code coverage reports and the results showing how much of the code is covered by tests.

tagged: tutorial phpunit tdd testdrivendevelopment introduction

Link: https://www.sitepoint.com/re-introducing-phpunit-getting-started-tdd-php/

CloudWays Blog:
Laravel Notification System On Slack And Email
Jul 27, 2017 @ 15:49:59

On the Cloudways blog Saquib Rizwan has continued the series showing how to use Laravel to build out an application the performs various kinds of notifications. In this latest article Saquib

In my previous articles, I helped you create a Laravel email sending system and a Contact Us form.

In this article, I will highlight another amazing feature of Laravel through a very basic Laravel notification system. Using this system, I will send a notification to the user by sending them an email and integrate Slack to setup the system for sending notifications on a Slack channel.

They start with setting up a new Laravel application, creating a "users" table and setting up the database. These instructions are for the Cloudways service but they give you an idea of what needs to be set up at least. Next is the code to set up the User model and to create a new notification for a "visit" to the page. First up is the email notification then comes the Slack notifications. Both use built-in functionality with the "Notifications" package in the framework to make the sending work.

tagged: tutorial laravel notification email slack introduction

Link: https://www.cloudways.com/blog/laravel-notification-system-on-slack-and-email/

TutsPlus.com:
Understand the Basics of Laravel Middleware
Jul 26, 2017 @ 12:53:38

On the TutsPlus.com site there's a tutorial recently posted sharing the basics of middleware in Laravel applications - reusable pieces of code that operate on the request and response during the execution of your code.

In this article, we'll dive deep into the Laravel framework to understand the concept of middleware. The first half of the article begins with an introduction to middleware and what it's actually used for.

As we move on, we'll cover how to create custom middleware in a Laravel application. After creation of your custom middleware, we'll explore the options available to register it with Laravel so that it could be actually invoked during the request processing flow.

The tutorial starts by explaining what middleware is and how it functions in the flow of the Laravel application (as well as possible uses). It then starts in on the creation of custom middleware designed to redirect mobile users to the "mobile site" for the service. With the test for that in place the post then shows how to apply the middleware to the application on a route.

tagged: laravel middleware introduction custom mobile example

Link: https://code.tutsplus.com/tutorials/understand-the-basics-of-laravel-middleware--cms-29147

Laravel News:
Two Best Laravel Packages to Manage Roles/Permissions
Jul 21, 2017 @ 09:48:46

The Laravel News site has posted an in-depth look at two packages Laravel users can implement to add in role/permission management: Bouncer and Laravel-permission.

Roles and permissions are an important part of many web applications. Laravel historically had a lot of packages for them, and improved the core code as well. So what is the situation on this market today? What packages are the best to use? I’ve picked two.

The post starts off by sharing a few reasons why you might even need these packages with the functionality that Laravel already includes. Most of the reasoning comes from the fact that the framework allows for checks but doesn't provide role/permission management. It then gets into what each of the package provide, how to install them and some example code to put them to use. It also looks at the database structure behind them and how they use that to store the authorization data.

tagged: laravel role permission package bouncer laravelpermission introduction tutorial

Link: https://laravel-news.com/two-best-roles-permissions-packages