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

TutsPlus.com:
How to Register & Use Laravel Service Providers
Jul 20, 2017 @ 19:08:19

On the TutsPlus.com site they've posted a new tutorial showing you how to register and use service providers in Laravel and how it relates to the service container functionality.

If you've ever come across the Laravel framework, it's highly unlikely that you haven't heard of service containers and service providers. In fact, they're the backbone of the Laravel framework and do all the heavy lifting when you launch an instance of any Laravel application.

In this article, we're going to have a glimpse of what the service container is all about, and following that we'll discuss the service provider in detail. In the course of this article, I'll also demonstrate how to create a custom service provider in Laravel.

The article starts with an overview of the service container and service providers, describing what they are and providing some example code/configuration to clarify the concepts. It then gets into the creation of your own custom service provider. In their case they create a provider that doesn't really do anything but it does help to show how to make it, register it and put it to use in a controller.

tagged: tutorial register use laravel service provider serviceprovider container

Link: https://code.tutsplus.com/tutorials/how-to-register-use-laravel-service-providers--cms-28966

SitePoint PHP Blog:
Symfony2 Registration and Login
May 11, 2015 @ 14:55:57

The SitePoint PHP blog continues their series looking at authentication and authorization in a Symfony2 application with part two of their series. This time author Taylor Ren focuses on the registration and login systems for your users.

In part 1, we discussed the basics of setting up a security system in our app (database and security.yml settings). We also covered the pre-registration stage where a user verifies their invitation status with the app. In this article, we will talk about registration, logins and post-login actions.

He starts with the registration side of things, showing how to create a simple form asking for a username, password (and confirming it), a homepage URL and email address. He shows how to link it to a User instance and render the form out to a Twig template. Once the request is submitted the user is created, including encoding (bcrypt) of the password. Next up is the login form that's linked to the "AuthenticationSuccessHandler" for post-success handling. The tutorial finishes off with a piece of code showing how to redirect the user back to their requested URL once authenticated.

tagged: symfony2 series part2 authentication register login tutorial

Link: http://www.sitepoint.com/symfony2-registration-login/

Marc Morera:
Lazy Commands in Symfony
May 08, 2015 @ 13:13:22

In the latest post to his site Marc Morera about the use of "lazy services" with Symfony2. In his examples, he uses a command line application to illustrate his point, but it could apply elsewhere as well.

Since Symfony version 2.4 you can define your controllers and commands as services. This is so useful as long as you need to treat your classes as much decoupled as possible. [...] When we define as lazy a service, this is not instanced when is injected, but only when is accessed. [...] The point here is to define our service intended to work with the model as lazy.

He shows how to implement this kind of "lazy" handling in a command, registering the commands into the services but not creating the instances of them until they're used. He includes some example code showing how this is set up and offers a few tips on the implementation and common issues to think about.

tagged: symfony2 command lazy service register tutorial

Link: http://mmoreram.com/blog/2015/05/08/lazy-commands-in-symfony/

Using Aura.Html with LeaguePlates
Mar 24, 2015 @ 15:51:13

Paul Jones has a new post to his site showing how to merge one of the components of the Aura framework with the templating library Plates, a part of the The League of Extraordinary PHP Packages. In this post he shows how to integrate the Plates rendering engine into the Aura.Html component for use as a view layer.

Aura has its own native PHP template package, Aura.View, a direct descendant of Savant and Solar_View, as well as a cousin to Zend_View. The v1 Aura.View package used to include a helper system. Once we realized that there was no reason to tie the helper system directly to the view system, we released the helpers as a standalone Aura.Html package. This means the helpers can be used in any PHP presentation code, framework-based or otherwise.

Plates lets you register functions against its own internal handling, referencing the different elements to be rendered. He includes a code example showing this integration and how they look used in a Plates template.

tagged: aura framework league plates templating library tutorial register

Link: http://paul-m-jones.com/archives/6111

Matt Stauffer:
Conditionally Loading Service Providers in Laravel 5
Mar 12, 2015 @ 15: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.

tagged: condition load service provider laravel5 appserviceprovider register

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

Matt Stauffer:
Extending Laravel's Application
Jan 27, 2015 @ 16:48:37

Matt Stauffer has a new post to his site today showing you how to extend Laravel's Application class to enhance its handling with other handy features.

It's seldom that we need to extend Laravel's core, and even when we do, it's most likely we're going to extend specific components, which is detailed in the docs. However, all of these instructions presume you're using the core Laravel Application (IOC Container) to extend the other classes. What if you want to extend the Application itself?

The example he provides is from his own real-world experience, based around changes they wanted to make in the default folder paths for things like the "storage" or "public" directories. He shares the three simple steps to making this custom handling work:

  • Extend the class
  • Register it in your application's bootstrap
  • Override/extend the current methods to add in your own functionality

In this case, changing the default paths is something that's under discussion already, but it gives a good simple example of changing that default functionality.

tagged: extend laravel application class override register tutorial

Link: http://mattstauffer.co/blog/extending-laravels-application

Rob Allen:
Registering Doctrine Type Mappings for standalone migrations
Nov 18, 2014 @ 16:50:47

In a previous post Rob Allen showed you how to use Doctrine migrations as a standalone tool in your applications. In this new post he takes that a step further and shows you how to use the type mapping functionality (allowing for more customized column handling).

Shortly after starting to use Doctrine Migrations as a standalone tool in my project, I came across this error message [about an unknown database type "bit"]. This means that I have a column in my database of type bit which is used for booleans in SQL Server, but confuses the MySQL platform as it's not a default mapping. To support this, you need to modify the database connection's Platform object to know about the new mapping. However, with the setup that I'm using, I didn't have access to the connection object that's automatically created in the Migrations AbstractCommand object. After poking around in the code for a bit, I discovered that the solution is to create the connection object myself and then attach it as a new helper to the ConsoleApplication object.

He includes the code you'll need to add to your "migrations.php" file to set up the mapping relating his "bit" type example back to a "boolean" type. While this specific example is for the "bit" mapping, it shows how any mapping type can be added in. Finally he adds the connection (the one he set the type on) to enable it to be included in the helper set collection.

tagged: register type migration doctrine database tutorial custom mapping

Link: http://akrabat.com/php/registering-doctrine-type-mappings-for-standalone-migrations/

Zumba Fitness Engineering:
Using Application Events to Hook in Plugins
Aug 09, 2012 @ 14:23:37

In this recent post on the Zubma Fitness Engineering site, Chris Saylor looks at using events in your applications to hook in plugins to easily (and dynamically) enhance functionality.

In many instances, having a plugin system (even for closed-source applications) is a convenient and safe approach to adding functionality to a product. It minimizes risk by not having to modify the core of the source. In this article, I’ll be discussing how we implemented a plugin system for our cart software to allow for plugins.

Its implemented a bit like the Observer design pattern - you "register" the listening event which can then be activated by a "trigger" method with the event's name. These events are stored in a registry (static) so they can be accessed across the application.

tagged: events plugin trigger register tutorial observer

Link:

Community News:
ConFoo Early Bird Deadline ends in 3 Days!
Jan 27, 2011 @ 14:36:31

If you're looking for a great conference to attend that's not just PHP specific (there's tracks for not just PHP but also Python, Java, Front-end development and Ruby) you should take a look at ConFoo happening March 9th through 11th in Montreal. The event brings together almost 150 different sessions into a packed three day event. They've just recently posted their schedule too.

PHP Québec, Montréal-Python, Montreal.rb, W3Qc and OWASP Montréal are proud to announce the second edition of the ConFoo Conference. From March 9th to 11th 2011, international experts in Java, .Net, PHP, Python and Ruby will present solutions for developers and project managers the prestigious Hilton Bonaventure Hotel, located in downtown Montréal.

If you want to get in on the Early Bird pricing, you'll need to act fast - it ends in three days (January 30th)! There's also an optional training event happening before the conference (March 7th & 8th) with three sessions on advanced PHP Development, Symfony2 and web standards.

tagged: confoo earlybird deadline register conference schedule

Link:

Community News:
Adobe Developer Week Starts May 10th
May 05, 2010 @ 16:19:51

As is mentioned on the Zend Developer Zone, the Adobe Developer Week will be starting up on Monday, May 10th and will offer free sessions for developers interested in learning about Adobe products.

During Developer Week, learn about the Adobe Flash Platform, including Adobe Flex, Adobe Flash Builder, Adobe AIR, Adobe Flash Player, and how it integrates with Adobe Creative Suite 5 technologies. This weeklong event features free, live webinars presented by Adobe technology experts. See live demos and have your questions answered by the experts during interactive Q&A sessions.

You can find out more information about the sessions offered and how to register for them on this page of the Adobe website.

tagged: adobe developer week session product register

Link:


Trending Topics: