News Feed
Sections




News Archive
feed this:

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

SitePoint PHP Blog:
Use Laravel Contracts to Build a Laravel 5 Twig Package
March 16, 2015 @ 11:52:13

The SitePoint PHP blog has a new tutorial posted showing you how to integrate Twig into a Laravel application with the help of the recently added "contracts" feature of the framework. Twig is a templating library that aims to be fast, secure and flexible for data output in multiple contexts.

Laravel 5 is finally out, and with all the awesome features it brings. One of the new architectural changes is the new Contracts Package. In this article we are going to understand the reasoning behind this change and try to build a practical use case using the new Contracts.

He starts with a brief look at what Contracts are and what it means to use them in a Laravel application. He then shows how to define the package installation (via Composer) to pull Twig in and register it with the application for future use. He creates a simple service provider to register Twig and return a new "TwigFactory" instance. This instance extends the "FactoryConnect" implementing the "ViewFactory" and, along with a custom "TwigView" object can be used just like you would normally output information via Blade.

0 comments voice your opinion now!
laravel contract twig output template handling provider interface

Link: http://www.sitepoint.com/use-laravel-contracts-build-laravel-5-twig-package/

Matt Stauffer:
Conditionally Loading Service Providers in Laravel 5
March 12, 2015 @ 10:16:35

Matt Stauffer has a new post to his site showing you how to conditionally load providers in your Laravel-based application with some additional code in the AppServiceProvider.

Since Laravel 5 flattened a lot of the environment-specific structures, much of the configuration that was once stored in different config directories for each environment has now moved into .env files. But one that can't just live in .env is the environment-dependent loading of service providers.

He starts with a look at the normal service provider loading process, using the application configuration and adding them to the "providers" list. This loads them every time a request is made, even if they're not needed. His solution adds some code to the "register" method in the AppServiceProvider class to check the environment (like "production" versus "dev") and loads different providers based on the result.

0 comments voice your opinion now!
condition load service provider laravel5 appserviceprovider register

Link: https://mattstauffer.co/blog/conditionally-loading-service-providers-in-laravel-5

Programming Are Hard:
Structuring my applications, Cont'd
March 09, 2015 @ 12:03:16

The Programming Are Hard site continues its look at structuring Symfony-based applications in part two (it's just two parts) building on the structure and foundation laid out in part one.

It really irks me when I see some design/architecture decisions other developers have made but there's no technical explanation. What packages did they use? What challenges did they face? What trade-offs were made? I'll go over some more specifics in this post.

He recaps some of the things covered in the previous post first, ensuring everyone is on the same page. He then gets into the concept of "bundles" and how they encapsulate functionality. From there he talks about commands, controllers, dependency injection and lots of other topics, each with their own summary and a bit of code where needed for clarification.

0 comments voice your opinion now!
structuring application symfony bundle command controller di form provider repository resource serialize

Link: http://programmingarehard.com/2015/03/05/structing-my-application-contd.html

Laravel News:
Debug Your App with the Laravel Debugbar
February 10, 2015 @ 09:34:12

The Laravel News site has a post introducing a tool you can use in your Laravel applications to help debug issues and performance, the Laravel Debug Bar.

The Laravel Debugbar by Barry vd. Heuvel is a package that allows you to quickly and easily keep tabs on your application during development. With a simple installation and powerful features the Debugbar package is one of the cornerstone packages for Laravel. The debugbar is already updated for Laravel 5 and I wanted to show you all the great features it includes.

The post includes instructions to get the debugbar installed (via Composer) and add it to your Laravel providers list. They walk through the basics of its features and screenshots of each. He also links you to the project documentation to provide more detail on each of the features.

0 comments voice your opinion now!
laravel debug debugbar toolbar library provider tutorial introduction

Link: https://laravel-news.com/2015/02/laravel-debugbar/

Mathias Noback:
Collecting events and the event dispatching command bus
January 13, 2015 @ 11:52:33

Mathias Noback has posted the next part of his command bus in PHP series today with a few suggestions about event handling and when it's a good idea to dispatch them.

It was quite a ride so far. We have seen commands, command buses, events and event buses. We distilled some more knowledge about them while formulating answers to some interesting questions from readers.

In this new post, his focus is on collecting the events that happen as a part of the command's execution. He uses his "UserSignedUp" event his his previous example and a "send welcome email" handler to show why it may not be the best idea to execute all events simultaneously. Instead, he recommends making use of event collections (a feature his SimpleBus library supports) to define "providers" that can collect the events that need to happen and delegate the execution of them one after the other. Example code is included all through the post of events, providers and commands that make use of this idea.

0 comments voice your opinion now!
commandbus command collect event provider dispatch tutorial

Link: http://php-and-symfony.matthiasnoback.nl/2015/01/collecting-events-and-the-events-aware-command-bus/

Acim.net:
Trait injection in Zend Framework 2
December 11, 2014 @ 11:55:56

Boban Acimovic has recently posted a tutorial showing you how to use traits in a Zend Framework 2 application to inject additional functionality into your pre-existing classes.

There are several tutorials on the Internet which explain how to use interface based dependency injection in Zend Framework 2. The idea is to make an initializer, figure out which interfaces a class implements and then inject appropriate dependencies using setters defined in the interfaces. Bad part about this is that in each class you implement such an interface you have to declare a property which would hold the injected object and also to implement the setter for it, which is defined in the interface, by the way. In order to simplify this further it is possible to write trait for each interface, but then why should not use just traits? Why do we need interfaces? Is this possible at all?

He includes some example code showing how to set up dependency injection for the traits (via a custom injector based on the "InitializerInterface") and make the autoloading easier. He shows how to add this to the provider configuration as an "initializer" and create the first example trait, a checker for data in user passwords. He then drops the functionality into a service class just by using the "use" keyword and the trait name.

0 comments voice your opinion now!
trait injection zendframework2 tutorial dependencyinjection service provider

Link: http://www.acim.net/2014/11/trait-injection-in-zend-framework-2/

Lorna Mitchell:
How to Choose PHP Hosting
October 10, 2014 @ 09:15:36

Lorna Mitchell has a new post today sharing some helpful hints to help you pick a good PHP hosting provider for your next application or website.

I've been thinking a lot about the state of hosting in PHP lately, mostly as a result of working with a few different clients on their setups (including one that bought brand new hosting a month ago and got a PHP 5.3.3 platform), and also being at DrupalCon and meeting a community who is about to make a big change to their minimum requirements. With that in mind, here are my thoughts and tips on choosing hosting.

She starts off with one of the bigger criteria she looks for in a host: the minimum PHP version available (some might have more than one, especially some PaaS). She suggests that even things like PHP 5.3 should be considered too old and should be passed over in favor of newer releases like 5.5 or even 5.6. She then talks about some of the benefits that come from using a newer platform and the current levels of adoption and performance by PHP version. Finally, she includes an unofficial list of hosts that have set themselves out as good, solid PHP-friendly providers, each with their own strengths and weaknesses.

0 comments voice your opinion now!
choose hosting provider paas dedicated version performance

Link: http://www.lornajane.net/posts/2014/how-to-choose-php-hosting

Chris Hartjes:
Data Providers and Arrays
October 28, 2013 @ 11:49:36

Chris Hartjes, testing guru, has a post talking about using arrays in data providers for your unit tests. More specifically about some odd behavior one developer was seeing in their tests.

I was asked a question on Twitter by Tex Morgan about a problem he was having with PHPUnit data providers. He was trying to pass in some data and kept wondering why PHPUnit was serializing the data instead of doing what he was expecting.

The issue (example code included) was in how the data providers are expecting the data to be returned. His test was expecting an array but the data provider was returning things incorrectly. As Chris points out, the provider should return an array of arrays. The fix is easy, but could be confusing to someone not used to this slightly unusual return format.

0 comments voice your opinion now!
data provider unittest array return value example

Link: http://www.littlehart.net/atthekeyboard/2013/10/26/data-providers-and-arrays/

The PHP.cc:
PHP 5.5 Generators
July 10, 2013 @ 11:49:04

In this latest post to The PHP.cc's blog, Sebastian Bergmann talks about using a new feature in PHP - generators.

A generator is an interruptible function that returns a sequence of values (using the yield keyword) instead of a single value (using the return keyword). Two things happen when the yield statement of a generator function is executed: the argument of the yield statement is yielded and the execution of the generator function is suspended. The execution of the generator function is resumed when the next value is requested.

He starts with a simple example, showing a basic foreach loop calling a generator to produce (yield) an incrementing number each time. He also provides a more "real world" use case - using generators as data providers for PHPUnit tests. His example generates a new "Address" object each time the provider is called with a bit of "randomized" information included.

0 comments voice your opinion now!
generators introduction phpunit data provider tutorial

Link: http://thephp.cc/viewpoints/blog/2013/07/php-5-5-generators

Gonzalo Ayuso:
Working with jQuery and Silex as RestFull Resource provider
June 10, 2013 @ 12:40:01

In a previous post Gonzalo Ayuso showed how to use Silex as a data provider to an AngularJS application REST-fully. In this new post he does the same thing but with jQuery this time.

The previous post was about how to use AngularJS resources with Silex. AngularJS is great and when I need to switch back to jQuery it looks like I go back 10 years in web development, but business is business and I need to live with jQuery too. Because of that this post is about how to use the Silex RestFull resources from the previous post, now with jQuery.

He includes the sample code showing the jQuery version of the application based on a "Resource" object. He also includes some samples of its use for the usual CRUD operations. You can get the full code from github.

0 comments voice your opinion now!
jquery rest tutorial resource silex provider

Link: http://gonzalo123.com/2013/06/10/working-with-jquery-and-silex-as-restfull-resource-provider


Community Events

Don't see your event here?
Let us know!


version php7 list example extension language introduction release api series security interview library framework opinion voicesoftheelephpant community podcast laravel laravel5

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework