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

ServerGrove Blog:
New Symfony installer the fastest way to start your Symfony project
March 27, 2015 @ 12:13:42

The ServerGrove blog has a new post today introducing the new Symfony Installer, a tool that can make getting started with a Symfony2 application quick and easy.

Yesterday, the Symfony team introduced the new Symfony installer. Its main goal is to help developers to create Symfony projects faster. Until now, installing Symfony to start a new project required a few steps. [...] The installer tries to do this in one step. It downloads a compressed file with all the code, including the vendors directory, so you don't need anything else to run Symfony for the first time.

The post shows you how to install the installer via a curl call to fetch the executable. They show how to use it to create a new project, making a demo project and the resulting application and web interface for the demo. They also mention some of the future work that's planned for the installer including HTTPS support and caching improvements. The post finishes up with a quick mention of the code "under the hood" using the Symfony console component.

0 comments voice your opinion now!
symfony installer introduction demo tutorial example command console

Link: http://blog.servergrove.com/2015/03/27/new-symfony-installer-fastest-way-start-symfony-project/

Kristopher Wilson:
Using Interfaces Effectively in PHP
March 27, 2015 @ 10:12:32

Kristopher Wilson has a quick post talking about how he thinks you can use interfaces effectively in PHP applications.

Yesterday, a question appeared on Reddit about the purpose of interfaces in PHP. While I was too late to the party to provide an answer to that thread (at least that would get noticed by anybody), I thought it was a great topic of conversation. So let's take a look at interfaces in PHP.

He introduces some of the basics around interfaces and provides some sample code showing how they're created and used (and extended). He talks about some good practices for implementing them in your classes and how this fits into the world of dependency injection. He also includes a bit about type hinting based on the interface implemented and how they can be seen as "contracts" in your code.

0 comments voice your opinion now!
using interface contract introduction example extend

Link: http://kristopherwilson.com/2015/03/26/using-interfaces-effectively-in-php/

NetTuts.com:
Design Patterns The Command Pattern
March 17, 2015 @ 12:42:22

NetTuts.com continues their series covering the basics of design patterns (in PHP) with a new article about the Command design pattern. This pattern is particularly useful for executing self-contained "commands" without other interaction.

In this article, we will be going through the command design pattern. As the name says, in this pattern we will be dealing with executing various commands. [...] Basically a pattern has numerous elements involved, which are as below. In the next section, we will be exploring each element with a code example. I will be taking the example of radio actions-very basic actions would be turning the radio on or off. So let's dive into each element.

Using the illustration of the radio, they go through the creation of the classes for the controls (on/off) and the two matching commands. The invoker is then told to execute the "turn off" command on the radio control object passed in. This sounds a little confusing but the code included in the article makes it clear how this implementation of the command is structured.

0 comments voice your opinion now!
designpattern tutorial series command pattern radio example

Link: http://code.tutsplus.com/tutorials/design-patterns-the-command-pattern--cms-22942

Sameer Borate:
Create a quick REST API using Slim framework
March 16, 2015 @ 10:16:40

Sameer Borate has a quick tutorial posted showing how to create a basic REST API with Slim, the popular microframework for PHP.

During a recent client project, I frequently needed to access a remote database table and update the same for certain fields. This was accomplished using phpMyAdmin on the server. However, it was getting tedious and was prone to accidental updates and deletes. [...] This is all a tedious process and prone to errors. One solution was to create a quick REST api wrapper around the remote database, using which developers could update the database table without any risk of corrupting the data and also with the added benefit of updating the table programmatically.

He uses an example of working with student data (SQL for the table included) and helps you get Slim installed and working with an Apache install. He covers the overall structure of the API he's creating and the code to help make it happen. Obviously he doesn't share the entire codebase - that would be too large. He does show examples of GET and POST requests for the student data to give you something to work from. He finishes the post with a few simple cURL calls to make requests to the API and the responses.

0 comments voice your opinion now!
rest api tutorial slim microframework example student

Link: http://www.codediesel.com/php/create-a-quick-rest-api-using-slim-framework/

Programming Are Hard:
Structuring my applications
March 06, 2015 @ 11:25:54

On the Programming Are Hard site there's a recent post looking at PHP application structure and how they handled the structure of one of their applications.

One of the biggest struggles for me, as an app developer, is coming up with an architecture that I'm happy with. It's something I wish other developers talked about more often. I thoroughly enjoyed Kris Wallsmith's SymfonyCon talk. It's very raw and real and doesn't come across as him talking down to anyone at all. Do I agree with everything he says? No, but that's not a bad thing. It's very insightful and I really enjoy taking a peak behind the curtains and seeing how other people do things. This is my attempt at doing just that.

He's broken down the structure into the overall parts and provided examples and summaries of each:

  • The use of packages
  • Entities
  • Events and Event Listeners
  • Commands and Handlers
  • Exceptions
  • Providers
  • Repositories
  • Security functionality
  • Services
  • Testing
  • Validation
  • Value Objects

Each section includes sample code and a description of where in the overall directory structure it fits. The setup is largely based on a Symfony application but it can be extracted (since it's mostly concepts) to most frameworks out there, even custom ones.

0 comments voice your opinion now!
application architecture structure symfony tutorial example

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

Anthony Ferrara:
Scalar Types and PHP
February 12, 2015 @ 11:25:47

Anthony Ferrara has tossed his own hat into the ring around the debate that's been going about the RFC for scalar type hints in PHP. In his post he agrees with (most of) the suggestions made in the proposal around strict, weak and the "compromise" of mixed typing.

There's currently a proposal that's under vote to add Pascal Martin's excellent post about it. What I want to talk about is more of an opinion. Why I believe this is the correct approach to the problem.

He starts off talking about the "all strict" angle that some suggested as the proper approach then moves into the "weak argument" explaining the difference between the two. He shares a bit of history around the problems detecting subtle bugs caused by typing issues and how it is definitely a problem that needs solving. Finally, he talks about the mixed-typing compromise and provides some code samples showing a common bug that can happen with weak typing.

0 comments voice your opinion now!
scalar type hint rfc opinion example weak compromise mixedtype

Link: http://blog.ircmaxell.com/2015/02/scalar-types-and-php.html

NetTuts.com:
Design Patterns The Simple Factory Pattern
January 27, 2015 @ 11:53:20

NetTuts.com has posted the next part of their series focusing on design patterns (and more specifically implementing them in PHP). In this latest post they look at a simple version of the Factory design pattern.

When you think of a factory, what comes to mind? For me, it's a place where things are created - that is, it's a centralized placed where things are produced. Later, the delivery of said products are done by the factory based on an order. Let's say that you're requesting a car. A factory will create one based on the specifications of the work order and will then deliver it once it's complete. Just as their real world counterparts, a software factory (that is, software that implements the factory design pattern), is an object that is responsible for creating and delivering other objects based on incoming parameters.

They mention the three different versions of the factory pattern but focus in on the simplest one (hence the "simple" in the title). They continue on with the car example, showing how to use a simple factory (a "carFactory") to build an instance of the "Car" class based on different classes of car types. The object is constructed when a "build" method is called with the type.

0 comments voice your opinion now!
designpattern simple factory car type example tutorial introduction

Link: http://code.tutsplus.com/tutorials/design-patterns-the-simple-factory-pattern--cms-22345

Coder on Code:
Design Patterns in PHP Adapters
January 26, 2015 @ 10:46:42

The Coder on Code site has posted a new tutorial covering the Adapter design pattern in detail. They talk about what the pattern is, what it can be useful for and include some code to illustrate.

The adapter pattern also referred as the wrapper pattern, I find that wrapper is a more fitting name since it describes clearly what this pattern does; it encapsulates the functionality of a class or object into a class with a common public interfaces. [...] Adapters are one of the easiest patterns to comprehend and at the same time one of the most useful ones.

He starts with some of the basic definitions of terms involved in the pattern: client, adapter and adapteee. His example centers around a notification manager class that lets you switch types between Twitter, Email and SMS messaging. His initial code has all of the message types handled in one class method. He shows how to refactor this out to an interface and a set of child classes, each with the corresponding handling in a "sendNotification" method. These are then used by an adapter in the main class to send the given message. This simplifies the main messenger class and contributes to the overall improvement of architecture and testability of the application.

0 comments voice your opinion now!
designpattern adapter example introduction client adapter adaptee messaging tutorial

Link: http://coderoncode.com/2015/01/25/design-patterns-in-php-adapters.html

SitePoint PHP Blog:
Writing API Documentation with Slate
December 15, 2014 @ 13:46:59

The SitePoint PHP blog has a new tutorial for the API developers out there showing you how you can use Slate for creating documentation. They point out a few other tools or formats you could use, but focus in on Slate, a Markdown-based tool that converts the result to HTML.

So you've built yourself an API. Perhaps it's RESTful, RESTlike or something else entirely. [...] There's one more thing, however. Thing is, an API is only as good as its documentation. That applies if it's for internal use only - perhaps it's for a JavaScript-based one-page app, or a mobile application - but even more so if it's for public consumption.

He includes an example of what the output looks like first so you know what the end result will be (and if it meets your needs). They then walk you through the installation of Slate and a few Ruby tools you'll need to generate the HTML output. He includes a simple example of the configuration and a simple document with four sections. He also shows how to use includes, alerts, tables and a sidebar. Finally he gives the "rake" command to build the documentation and how to you can push the result up to your own GitHub Pages.

0 comments voice your opinion now!
slate api documentation tutorial install configure example

Link: http://www.sitepoint.com/writing-api-documentation-slate/

Hack Blog:
Async - Cooperative Multitasking for Hack
December 08, 2014 @ 11:56:54

On the Hack blog there's a new post talking about async, a feature in Hack that allows for code to "cooperatively multitask". This gives the language a way to keep moving on in the execution without having to wait for things like database queries or remote file fetches to finish.

This is somewhat similar to threading, in that multiple code paths are executed in parallel, however it avoids the lock contention issues common to multithreaded code by only actually executing one section at any given moment. "What's the use of that?", I hear you ask. You're still bound to one CPU, so it should take the same amount of time to execute your code, right? Well, that's technically true, but script code execution isn't the only thing causing latency in your application. The biggest piece of it probably comes from waiting for backend databases to respond to queries.

She gives the example of pulling in a remote file (HTTPS, where there's a bit more latency) and how to use async, await, WaitHandle, and Awaitable to work around the timing issue. She shows how to make a method asynchronous and how to join the results of the operation back up with the rest of the script. This includes the use of various "handles" including RescheduleWaitHandle, SleepWaitHandle and the AwaitAllWaitHandle. She shows the integration of a custom cURL handler that makes use of this processing, marked async, to multithread the requests to the remote server(s).

0 comments voice your opinion now!
hack async asynchronous multitasking curl example remote fetch language

Link: http://hhvm.com/blog/7091/async-cooperative-multitasking-for-hack


Community Events

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


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

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