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:
StackPHP Explained
April 23, 2015 @ 11:40:02

The SitePoint PHP blog has a tutorial posted today that wants to help you understand StackPHP, the project centered around middleware, specifically related to the Symfony2 HttpKernelInterface.

Today we are going to look at StackPHP and try to understand what this thing is all about. Although this post will have some code, this article will be rather theoretical as we are interested in learning what StackPHP actually is, where it comes from and why it is useful. As the front page of the StackPHP project says, Stack is a convention for composing HttpKernelInterface middlewares. But, in order to actually understand this definition, we will have to cover a few concepts first. At the end, we will also illustrate the concepts we learned in the context of StackPHP with some example code.

They start with a brief look at the HttpKernelInterface and how it works with the overall request and response flow of a typical application request. From there they describe the Decorator design pattern that will be used to augment the request/response objects as they're going through the middleware process. Following this they look at how StackPHP fits into this picture and provides a few code examples showing both basic and a bit more complex middleware handling (including the use of StackBuilder).

0 comments voice your opinion now!
stackphp tutorial middleware httpkernelinterface symfony2 introduction

Link: http://www.sitepoint.com/stackphp-explained/

ServerGrove Blog:
Symfony2 components overview OptionsResolver
April 23, 2015 @ 08:23:32

The ServerGrove blog has posted another in their spotlights on specific Symfony2 components. In this latest post they look at the OptionsResolver component.

In the 13th post of the Symfony2 components series we will be talking about one little but extremely useful component: OptionsResolver. This component helps us to reduce the boilerplate code required to create an options system with default parameters. As stated in the official docs, is array_replace on steroids.

They start with a common situation, wanting to use options from user input, but only if they exist, and otherwise provide a default. This includes the use of the array_replace function but with the OptionsResolver there's an even easier way. A simple example is included showing how to use it to define options (and throw an exception when an undefined one is set). They show how to use a closure to set defaults on a specific option with more complex logic and how to use the validation and normalization handling.

0 comments voice your opinion now!
optionsresolver component symfony2 overview options

Link: http://blog.servergrove.com/2015/04/13/symfony2-components-overview-optionsresolver/

ServerGrove Blog:
Symfony2 components overview Filesystem
April 22, 2015 @ 10:29:32

The ServerGrove blog has posted another in their series of Symfony2 component spotlights with a look at the Filesystem component.

The 15th post of the Symfony2 components series is focused on the Filesystem component, which provides some basic utilities to work with the filesystem. It extends PHP built-in functions such as mkdir() or copy() to make them more portable and easier to use and test.

They start by stating the common problems with working in the file system from PHP and the warnings/errors that can come with them. They show how this kind of thing can be prevented with the Filesystem component and the functionality it provides. They also list some of the other useful functions (besides mkdir and touch previous mentioned) including: chmod, rename, makePathRelative and mirror. They also briefly mention the file locking ability the component has to prevent issues with multiple services interacting with the same files.

0 comments voice your opinion now!
symfony2 component overview filesystem introduction

Link: http://blog.servergrove.com/2015/04/22/symfony2-components-overview-filesystem/

SitePoint PHP Blog:
Symfony2 Console Getting Started with Console Helpers
April 09, 2015 @ 10:44:03

If you've ever worked with the Symfony Console component and wanted to enhance the experience with some additional functionality, check out the latest tutorial from the SitePoint PHP blog: Symfony2 Console: Getting Started with Console Helpers.

In this tutorial, I'll share my experiences and we'll give some extra love to the console helpers, which provide us with a large collection of handy functions. There are a lot of reasons to create console commands in your projects: sending emails, exporting/importing data, creating users, and so on. [...] By the end of this post, we want to be able to create a basic console command to generate some output - any output will do - only the way to getting there is important. Near the end, we'll discover some console helpers in order to create some nice interactions between users and the interface.

He starts by helping you get the component installed via Composer and creating the first simple command line script (a ConsoleApplication). He shows how to add in a basic "hello world" command (conveniently named "BasicCommand") and the result when executed. With this in place, he starts in on three helpers:

  • Question Helper
  • Table class
  • Progress Bar

Each includes the code needed to implement it and the resulting output. You can find out more about the component in the Symfony2 documentation.

0 comments voice your opinion now!
symfony2 console tutorial command helpers introduction question table progressbar

Link: http://www.sitepoint.com/symfony2-console-getting-started-console-helpers/

SitePoint PHP Blog:
Best PHP Framework for 2015 - SitePoint Survey Results
March 30, 2015 @ 11:59:00

In a new post to the SitePoint PHP blog editor Bruno Skvorc shares the results of the PHP framework survey the site posted a month back. In it they asked developers for their opinions on favorite frameworks (not necessarily the one they use, but their own personal opinion). For anyone that's been keeping up with the current state of PHP frameworks, the results aren't all that surprising though.

One month ago, we started the annual SitePoint framework popularity survey. Now that the month has expired, it's time to look at the results and to distribute the prizes. The response was a whopping ~7800 entries, far more than any other survey we've held so far, and even after filtering out invalid entries we end up with a formidable number of valid participants.

According to the results the most popular framework, by far, was Laravel. Coming in second was Symfony2 and third the Nette framework. They did ask for different opinions for personal versus business choices but the results track the same between the two. He also splits out the data into the top results by country and by the age of the people who responded.

He finishes off the post with some of his own thoughts on why Laravel was the clear winner with only some of it having to do with the framework itself. He points out the related projects, "near perfect documentation" and other things (like Laravel's own subreddit). He suggests that, even though open source and "free" tend to go together, spending money and a good amount of time on a project can help ensure it succeeds. He also offers some practical advice for those wanting to give their project a boost:

Spread the word, analyze solutions from other people, discuss them. Be open, be transparent. Have an official blog, get a StackOverflow tag, justify your decisions, get in touch with popular publications which can help promote your framework if you present it well enough.
0 comments voice your opinion now!
framework survey results opinion popularity 2015 laravel symfony2 nette

Link: http://www.sitepoint.com/best-php-framework-2015-sitepoint-survey-results/

SitePoint PHP Blog:
User Authentication in Symfony2 with UserApp.io
March 19, 2015 @ 09:18:18

On the SitePoint PHP blog Daniel Sipose has written up a tutorial showing you how to use the UserApp.io service to authenticate users for your Symfony2 applications.

UserApp.io is a handy user management tool and API. It provides a web interface to deal with user accounts (and the many features this involves) and an API to hook them into your own web application. The purpose of this service is to make it easier and safer to manage user authentication by not having to worry about that on your own server. It has SDKs and various wrappers for many programming languages and frameworks and the price is affordable. Yes, it comes with a price but you can get started freely with quite a lot of things to play around with.

He makes use of this library (his own creation) and the UserApp.io SDK to hook into Symfony2's own Security component authentication handling. He starts by explaining some of the classes he'll be creating including the form authenticator, a user provider, the logout handler and an custom exception. The full code is included for each as well as the changes you'll need to make to the YAML configuration to hook it all together.

0 comments voice your opinion now!
user authentication symfony2 userappio service tutorial

Link: http://www.sitepoint.com/user-authentication-symfony2-userapp-io/

ServerGrove Blog:
Symfony2 components overview Stopwatch
March 17, 2015 @ 11:12:40

The ServerGrove blog has returned with another of their overviews of a specific Symfony2 component. In this new article they talk about the Stopwatch component, a useful way to help in profiling execution of your application.

It's been a long wait, but we are back again with the Symfony2 components series. In the 12th post of the series, we cover the Stopwatch component. Even though is one of the smallest ones, that does not mean is not important, as plays a crucial role when we want to profile our code.

Since the article series is about working with the component individually, they show you how to get it installed via Composer by itself. They include a simple example of it in use, starting/stopping a "test" timer, getting the duration and getting the overall memory consumption. They also include a slightly more complex example timing the execution of a Fibonacci sequence, reporting back the execution time on each line of output. The article also covers other features like the "lap" method, sections for grouping events and the difficulties you'd have extending it.

0 comments voice your opinion now!
symfony2 component overview stopwatch introduction

Link: http://blog.servergrove.com/2015/03/16/symfony2-components-overview-stopwatch/

stfalcon.com:
Increasing project productivity in Symfony2 from Doctrine2 ORM
March 16, 2015 @ 13:55:36

In this tutorial to the stfalcon.com site Sasha Lensky talks about some things you can do to help boost the performance of your Symfony2 application with a few tweaks in how Doctrine is used.

I have been trying to write this article for a long time, but just couldn't get around. Finally, I pulled myself together and did it. So, what will we discus ... I will share some techniques about working with Doctrine2 ORM, which will help to improve the site performance on Symfony2 (precisely any site that uses Doctrine2 ORM). I have created a project and put it on GitHub as a visual guide, so anyone can test my words in action now.

He shares five tips and includes code examples and results (based on the Profiler toolbar) for each:

  • Downloading all necessary connections
  • Updating multiple entities by request
  • Hydration waiver
  • Using Reference Proxies
  • Using Symfony Profiler Toolbar

That final tip about the Profiler toolbar is actually one used in the rest of the examples too, showing how to get that other information from the tool.

0 comments voice your opinion now!
doctrine2 symfony2 orm performance tips profiler toolbar

Link: http://stfalcon.com/en/blog/post/performance-symfony2-doctrine2-orm

SitePoint PHP Blog:
Building an Ad Manager in Symfony 2
October 28, 2014 @ 13:29:31

In a recent post to the SitePoint PHP blog Hugo Giraudel shows you how to create an ad manager as a Symfony-based application. His ad manager allows you to use videos, images or HTML content to create and cache advertisements to add to any application.

The main idea was to build an ad manager. What the hell is an ad manager you say? Let's say you have some places on your site/application to display ads. We do have things like this on our site, and one of our teams is (partially) dedicated to bringing those places to life with content. Now for some boring reasons I won't list here, we couldn't use an existing tool, so we were doomed to build something from scratch. As usual, we wanted to do a lot without much coding, while keeping an overall simplicity for the end user (who is not a developer). I think we came up with a fairly decent solution for our little project.

He uses ESI rendering with Twig templates to identify the ad to return, grab its configuration and render it back to the requesting client. He includes a global configuration (URI and allowed types) an an example of a per-ad configuration file that includes the cace settings, data type and link. The code is also included to consume the request for the ad and render the result. There's also a "randomize" method that picks a random item from the array by weight. Finally, he includes the view templates that can be used to render the results - one for the main ad layout and a few for each type (video, image or HTML).

0 comments voice your opinion now!
advertisement manager symfony2 application tutorial

Link: http://www.sitepoint.com/building-ad-manager-symfony-2/

NetTuts.com:
Basic Functional Testing With Symfony 2's Crawler
October 23, 2014 @ 10:21:33

In this new tutorial on the NetTuts.com site Andrew Perkins shares a way that you can use Symfony2's own Crawler to do some simple functional testing.

Testing your web applications is one of the best things you can do to ensure its health, safety, and security, both for the app and your app's visitors. Symfony 2 offers a complete integration testing suite that you can use to make sure your applications run just as you expect. Today we'll look at how we can use Symfony 2 and PHPUnit, the testing framework that it employs, to write basic functional tests using the Crawler.

He starts off by helping you get a Symfony2 instance installed, the Standard edition, and grabbing the latest PHPUnit phar file from the project's site. He then gets into the actual development of the Crawler bundle, using the command line Symfony tool to do some of the automatic code generation for you. They show how to execute the PHPUnit tests and make the first controller/action/routes for the sample pages to test. He then makes the first test file, extending the "WebTestCase" class from the Symfony2 components. He makes a simple client, executes the request and shows how to test various parts of the response (including an example of mimicking the clicking of a link).

0 comments voice your opinion now!
crawler symfony2 functional testing tutorial introduction

Link: http://code.tutsplus.com/tutorials/basic-functional-testing-with-symfony-2s-crawler--cms-20666


Community Events

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


voicesoftheelephpant extension laravel opinion api release series interview framework community conference introduction library php7 podcast xdebug performance example symfony2 version

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