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

TutsPlus.com:
Test-Driven Development With Laravel & Doctrine
Feb 02, 2016 @ 13:39:47

On the TutsPlus.com site they've posted a new tutorial showing you how to do test-driven development with Laravel and Doctrine, making use of Doctrine's own testing functionality inside of a Laravel application for PHPUnit based unit testing.

As a PHP developer, you may use the Test-Driven Development (TDD) technique to develop your software by writing tests. Typically, TDD will divide each task of the development into individual units. A test is then written to ensure that the unit behaves as expected. [...] TDD verifies that the code does what you expect it to do. If something goes wrong, there are only a few lines of code to recheck. Mistakes are easy to find and fix. In TDD, the test focuses on the behavior, not the implementation. TDD provides proven code that has been tested, designed, and coded.

[...] PHPUnit is the de-facto standard for unit testing PHP. It’s essentially a framework for writing tests and providing the tools that you will need to run tests and analyze the results. PHPUnit derives its structure and functionality from Kent Beck’s SUnit.

He briefly talks about some of the assertions that PHPUnit has to offer before getting into the support that Laravel includes and how to configure it so Doctrine can work with your database. He then talks about Doctrine, briefly introducing the popular database abstraction tool and how to integrate it with a Laravel application. From there he starts in on the tests themselves, showing code that uses fixture data to create several tests for Post and Comment data.

tagged: testdriven development tdd laravel doctrine fixture tutorial

Link: http://code.tutsplus.com/tutorials/test-driven-development-with-laravel-doctrine--cms-25563

Tighten.co:
Statamic v2 Beta: First Impressions of a new Laravel-based flat-file CMS
Feb 01, 2016 @ 13:37:14

On the Tighten.co blog they've posted their own review of Statamic, the flat-file based content management system with a Laravel backend. Statamic is a project that hopes to provide easy content management, responsive layouts and plenty of features to make an easy-to-use and robust CMS.

Among the developers I know who used to use ExpressionEngine but have since left, most work in Craft and/or Laravel. I kept hearing folks mention Statamic, but all I knew about it was that it was flat file, which wasn't particularly compelling to me.

Fast forward two years, and they've re-written the entire application to run on Laravel (now released as v2 beta). [...] Their documentation is hilarious, the community is welcoming and helpful, and the code—granted, I'm only a few weeks in—seems super easy to work with. So, what's the deal? Why have we set up Tighten's blog on Statamic?

The post then goes on to talk about the "quest" for a good Laravel-based content management system. They also talk about some of the essentials they see a CMS needing to be effective: good user interaction (UI/UX), how much and how difficult it is to customize and how it is configured. For each point they talk about how Statamic does things and their own verdict on the software and how good it does at filling these requirements.

tagged: statamic beta laravel content management system cms flatfile

Link: http://blog.tighten.co/statamic-v2-beta-first-impressions-of-a-new-laravel-based-flat-file-cms

Laravel News Podcast:
LN 08: Database Backups
Jan 28, 2016 @ 12:56:39

The Laravel News podcast with host Eric Barnes has posted their latest episode: Episode 8 - Database Backups.

Episode 8 of the Laravel News podcast is now out.

This episode features special guest Freek Van der Herten talking about backups, Test Driven Laravel, WordPress & Laravel, and PDF generation.

You can listen to this latest episode either by subscribing over on iTunes or pointing your feed reader at the RSS feed and grabbing the latest from there. If you're interested in listening to previous episodes, be sure to check out the podcast archive section on the Laravel News site.

tagged: laravelnews laravel podcast news ep8 ericbarnes database backup

Link: https://laravel-news.com/2016/01/ln-08-database-backups/

Alfred Nutile:
Feature Flags In Laravel
Jan 26, 2016 @ 09:45:02

In a post to his site Alfred Nutile has posted a guide to integrating feature flags (toggles) into your Laravel-based application to show and hide features based on different criteria. He makes use of the Atriedes/feature library to handle some of the logic and decisions for him.

We are working on using FeatureFlags or Toggles in our applications. For one we are aiming to do all our work on mainline branch at all times so this would be a key coding discipline to use FeatureFlags so we can hide a feature in progress knowing it will not interfere with the application.

[...] One key thing, as I use this in Laravel, is I will try and mix this with the existing Authorization workflow that is already present. This gives me some already prepared ways to think about this both at the view layer, model layer and controller layer and where to register these states.

He shows how to get the "feature" library installed and integrates it with the Laravel application via two service providers: one for the core flag handling and the other for defining the policies themselves. He includes the code for each of these providers and makes some simple "can see" and "can add" policies for a Twitter field. He also shows the code for the evaluation methods and how to make use of the functionality in a menu (template). He also includes a screencast showing how it all works in a live application.

tagged: featureflag toggle tutorial laravel atriedes library screencast feature

Link: https://alfrednutile.info/posts/175

Matt Stauffer:
Multiple authentication guard drivers (including API) in Laravel 5.2
Jan 25, 2016 @ 09:24:31

Matt Stauffer has a new post in his series looking at the features in the latest version of the Laravel framework (v5.2) with this look at guard drivers and how 5.2 allows you to use more than one at once.

Let's get back to Laravel 5.2 features, shall we? 5.2 introduced a significant boost to the power of the entire authentication system, including making it much simpler to have multiple "guards" running at once. The default authentication guard in Laravel prior to 5.2 (now named the web guard) is your traditional web-based application authentication layer: username and password post to a controller. [...] But what if you want to have an API running in the same app, and it uses JSON web tokens (or some other stateless, non-session authentication mechanism)? In the past you'd have to jump through a lot of hoops to have multiple authentication drivers running at the same time.

He shows how to edit the auth.php configuration file to add in more "guard" instances to the default request handling. He also talks about the new driver that backends the "api" guard: the token driver. He briefly introduces the driver and talks about how it works with the current authentication setup. He also looks at changes you can make to use non-default drivers in your auth requests and how to set up your own custom drivers.

tagged: multiple authentication api token guard driver tutorial laravel

Link: https://mattstauffer.co/blog/multiple-authentication-guard-drivers-including-api-in-laravel-5-2

Laravel News:
Laravel Release Process
Jan 21, 2016 @ 09:22:33

On the Laravel News site they've posted about the framework release schedule for the next few minor version releases and the support levels each will include.

At Laracon 2013 in Washington D.C., Taylor announced the first official release cycle for the framework. [...] By having an official release cycle, it allows us as end users to plan around when we need to perform upgrades and also the dev team a way of knowing what is coming and when. Since this announcement all new releases have followed this schedule.

He talks briefly about the 5.1 release of the framework and how it changed up the flow by adding long term support (two years for bugfixes, three for security). He then outlines the release schedule from the 5.1 LTS release out to 5.5, the next LTS release. This is only a guideline for now and could possibly change in the future but at least it gives an idea of the schedule of things to come.

tagged: laravel framework release process schedule longtermsupport version

Link: https://laravel-news.com/2016/01/laravel-release-process/

Johannes Siipola:
How to use Eloquent ORM migrations outside Laravel
Jan 20, 2016 @ 11:55:10

On his site Johannes Siipola has posted a tutorial showing how to use the Eloquent ORM outside of Laravel, more specifically the migration functionality to manage database table creation/updates/deletions.

Laravel's Eloquent is one of the most fluent and expressive ORM's available for PHP. However, unlike some of its competitors like Doctrine or Propel, it's highly tight to the Laravel ecosystem in some ways. It's still possible to use Eloquent outside Laravel with a bit of work.

[...] If you use Eloquent outside Laravel, you will be missing one of it's best features: database migrations. [...] There has been some effort in order to use Laravel migrations outside the framework, but it hasn't been possible because the migrations require a complete instance of Laravel to run. In this tutorial, we are using framework agnostic Phinx migration library instead.

He then shows how to install the packages needed for the example: Slim framework, the Eloquent ORM and Phinx. He then shows how to set up the database and Phinx configurations and create your first Phinx migration. Inside this migration he makes use of the Eloquent schema builder functionality to create a simple "widgets" table. He ends the post showing you how to create the simple Slim application and work with the model they've created to both save and read data easily.

tagged: eloquent laravel outside orm migration phinx slimframework tutorial

Link: https://siipo.la/blog/how-to-use-eloquent-orm-migrations-outside-laravel

NetTuts.com:
Getting Started With Laravel
Jan 20, 2016 @ 09:06:16

On the NetTuts.com site there's a tutorial posted helping you get started with Laravel, one of the more recently popular PHP frameworks.

Almost all CMS systems use it, including Joomla, Drupal and WordPress, and of course many frameworks like CakePHP use it as well. I arrived at Laravel in early 2014 and I was instantly hooked. It not only uses OOP, it requires it! I have to admit, this was a challenge, but I learned so much thanks to it, and it has made the code I write for other systems a lot better too!

In this article I’ll show you how to get started with Laravel by installing everything that’s needed to run the system, showing you how to use Laravel Homestead - a great virtual machine - and finally, how to install Laravel itself.

The tutorial starts with an introduction of what the framework is and briefly mentions some of its main advantages: standardization, elegance and speed. It then gets into the steps for installing Laravel and setting up a basic application:

  • Install Composer
  • Install Git
  • Install VirtualBox and Vagrant
  • Download the Box (Homestead)
  • Install the Homestead CLI
  • Configure Homestead
  • Launching the Vagrant Box

Don't worry, each of these steps comes with all the commands and config file changes you'll need to make. With the environment up and running they finish the article off with a Composer require command to install a Laravel application and how to test that it's up and running.

tagged: laravel framework gettingstarted introduction homestead environment tutorial

Link: http://code.tutsplus.com/tutorials/getting-started-with-laravel--cms-25386

Laravel News:
WordPress and Laravel
Jan 19, 2016 @ 11:33:11

The Laravel News site has a post sharing some of the tools you can use to connect your Laravel and WordPress applications directly and, potentially, allow for reading and writing between them.

WordPress is one of the most popular open source applications and that means many people are comfortable using its admin to manage their site. There are times when building out a site this is advantageous as it prevents you from having to retrain the user on how to manage content, menus, photos, and more. A popular way of setting up a site like this is to use WordPress as the admin and then build out the frontend in a framework such as Laravel.

For each package they include a brief description of what it has to offer and a code sample of it in use:

They also include links to a few other tutorials showing how to make the integration, some with their own (somewhat simpler) tools to bridge the gap.

tagged: laravel wordpress interoperability library tutorial

Link: https://laravel-news.com/2016/01/wordpress-and-laravel/

Freek Van der Herten:
Some Laravel Homestead tips
Jan 18, 2016 @ 12:27:30

Freek Van der Herten has a post to his site sharing some Laravel Homestead tips you can use to optimize and customize your current Homestead installation.

Homestead is a pre-packaged Vagrant box that includes a good development environment. It was made and is maintained by Taylor Otwell, the creator of Laravel. In this post I’d like to share some tips regarding this box.

His list of tips includes:

  • Map all sites at once
  • Use a bash function to work with a globally installed homestead
  • Map your dotfiles directory

Each tip comes with a bit of code/configuration changes to make to be able to use the functionality and configure the instance correctly.

tagged: laravel homestead tips configuration command example

Link: https://murze.be/2016/01/some-laravel-homestead-tips/