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

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - Web Example
Mar 30, 2016 @ 10:50:17

In a previous post Loïc Faugeron showed you how to take all of the components he'd talked about so far and make a simple API endpoint. In this latest post he takes the same functionality and makes a web-facing example instead.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console. We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory.

Finally we've started to put all this knowledge in practice by creating a "fortune" project with an endpoint that allows us to submit new fortunes.

In this article, we're going to continue the "fortune" project by creating a page that lists all fortunes.

He goes through a similar process as before, but with a few changes to make it output a web page instead of API (JSON) results:

  • Create the Controller
  • Configure related routing
  • Create the logic to list all current fortunes
  • Putting the "wiring" in place to connect it to the database
  • Creating the view to output a simple page with the fortune list

It's that last step that's different, resulting in a simple (non-templated) page being output with HTML markup. He then refactors this to use Twig as the templating output layer, removing the output generation from the application logic.

tagged: ultimate developer guide symfony web example component combine tutorial

Link: https://gnugat.github.io/2016/03/30/ultimate-symfony-web-example.html

Loïc Faugeron:
The Ultimate Developer Guide to Symfony - API Example
Mar 25, 2016 @ 10:31:09

Loïc Faugeron has posted another article in his "Ultimate Developer Guide to Symfony" series today. In this new article he shares an API example making use of the knowledge gained from the other articles to create a simple project.

In this guide we've explored the main standalone libraries (also known as "Components") provided by Symfony to help us build applications: HTTP Kernel and HTTP Foundation, Event Dispatcher, Routing and YAML, Dependency Injection and Console.

We've also seen how HttpKernel enabled reusable code with Bundles, and the different ways to organize our application tree directory. In this article, we're going to put all this knowledge in practice by creating a "fortune" project with an endpoint that allows us to submit new fortunes.

He starts by creating the project (via Composer's create-project command), sets up a basic routing configuration and installs PHPUnit for testing. He then shows the creation of the controller - test first - to handle the "fortune" endpoint requests. He then comes back in and adds in some logic around the submission including matching tests. This is then refactored further to use Doctrine to insert the contents into a database. Additional code is provided showing how to "wire it all together" and create the database structure. The entire post takes the TDD approach so tests for all submission functionality are included.

tagged: ultimate developer guide symfony api example component combine tutorial

Link: https://gnugat.github.io/2016/03/24/ultimate-symfony-api-example.html

Matthew Turland:
PHPUnit + XHProf = BOOM!
Oct 14, 2015 @ 09:38:22

Matthew Turland has a post to his site sharing his experience with the PHPUnit and XHProf combination...and the unfortunate result that made every test fail.

I ran into an issue recently while trying to run PHPUnit tests in an environment using XHProf. Google didn’t prove to be much help, so I thought I’d document the problem and solution here for posterity.

When I ran my tests, each failed with the same cryptic error and no backtrace: "Attempted to serialize unserializable builtin class PDO" The cause was the culmination of two rather unfortunate circumstances.

He shares the two problems that causes this issue - one being XHProf's use of globals (where its PDO connection is stored) and the other is the @backupGlobals setting in PHPUnit that's enabled by default. This makes PHPUnit to try to backup that PDO connection by serializing it but can't, hence the failure. He points out a pull request that aims to fix the issue but recommends disabling the globals backup for the time being if you don't have a need for it.

tagged: phpunit xhprof combine globals pdo error backup

Link: http://matthewturland.com/2015/10/13/phpunit-xhprof-boom/

Codeception Blog:
The Locator Class
Sep 27, 2012 @ 09:50:34

The Codeception blog (a BDD testing tool) has a new post on using their Locator class to create more complex tests based on XPath or CSS selectors.

In the latest Codeception 1.1.4 new Locator class was introduced. Basically it should simplify your life in writing complex XPath or CSS locators. Right now it has minimal, yet useful functionality.

The post shows how to combine more than one item for location with either a tag, CSS-based or XPath-based selector. It also shows how to use the "tabindex" method to simulate the movement through a page using the "Tab" key. Finally, there's a quick piece of code showing how to locate an item based on the "href" value. For more information on using Codeception, check out their documentation or the project's main site.

tagged: locator class css xpath combine tab href


Watermark processing on images using PHP and GD
Sep 09, 2011 @ 12:36:06

On the Script-Tutorials blog today there's a new tutorial posted showing you how to easily add watermarks to your images dynamically, either as a part of a cache generation or on upload.

I will show you how to use GD library. And, main task today is adding watermark to image and generate result as PNG image into browser. We will using PHP and GD library. This is nice library to work with images at server side. Also (as additional tasks) I will draw little frame over image and will draw some text. Between, you can use this method (of adding watermarks in realtime) to protect original photos.

Full code for the script is included in the post, showing the combining of two images into the one finished product. The code is also available for download if you'd like to get hacking right away.

tagged: watermark image gd combine tutorial


Gonzalo Ayuso's Blog:
Speed up page page load combining javascript files with PHP
Feb 21, 2011 @ 13:01:54

Gonzalo Ayuso has a handy performance tip for getting that little bit extra speed from your page load times - combining Javascript with PHP files.

One of the golden rules when we want a high performance web site is minimize the HTTP requests. Normally we have several JavaScript files within our projects. It’s a very good practice to combine all our JavaScript files into an only one file. [...] But if your project is alive and you are changing it, it's helpful to spare your JavaScript files between several files. [...] So we need to choose between high performance and development comfort.

He includes a quick script that runs through your javascript directory (recursively), grabs all of the javascript content from each, combines and minifies them to serve gzip compressed out to the browser.

tagged: javascript tutorial combine minify gzip page load performance


20 Useful PHP + jQuery Components & Tuts for Everyday Project
Apr 07, 2009 @ 12:56:16

Noupe.com has posted a list of twenty useful PHP and jQuery components (and tutorials) that could be useful in everyday projects:

When you combine some neat functionality courtesy of PHP with the cleverness of jQuery you can produce some pretty neat effects. In an effort to help you take it up a notch, we’d like to share some methods for helping your site anticipate a user’s next move.

Included in the list are components/tutorials like:

See the full post for even more great PHP+jQuery information.

tagged: jquery component tutorial list project combine backend frontend


PHPImpact Blog:
Server-side Marker Clustering with PHP and Google Maps
Feb 27, 2009 @ 10:25:14

On the PHP::Impact blog Federico Cargnelutti points out a PHP library that lets you do clustering on Google Maps. What's clustering?

As maps get busier, marker clustering is likely to be needed. Marker clustering is a technique by which several points of interest can be represented by a single icon when they’re close to one another.

The tool, created by Mike Tuupola, lets you break up the map into cells and place points inside them. When there's more than one point in a general area, an extra icon is created to reference those points together (cleaning up the map and preventing you from having lot of little Google Maps markers cluttering up your map. Mike also has a blog post about the library showing it in a bit more detail.

tagged: server clustering mark googlemaps miketuupola library combine


Matt Stone's Blog:
Using the Zend Framework ACL Library in Codeigniter
Dec 22, 2008 @ 09:30:09

Since the Zend Framework is mostly a library of components behind a framework structure, its parts can also be used individually if need be. In this new post Matt Stone shows how to combine the Zend_Acl component (for access control) with a CodeIgniter framework application.

In this post I will explain how to build simple access control functionality for your Code Igniter application using the Zend Framework ACL library. To follow this tutorial you will need a working installation of Code Igniter and a database. You will also need to download the Zend Framework.

He goes through the whole process - code and all - for pulling in and using the Zend_Acl library complete with a database (schema and inserts provided) as well as a sample controller for CodeIgniter to test things out.

tagged: zendframework codeigniter zendacl library combine component


John Highland's Blog:
LifeStreaming Is Simple As Pie
Apr 25, 2008 @ 12:56:33

John Highland has a quick tutorial showing how to create a lifestream with PHP out of all of the RSS feeds surrounding the multiple social networking and blogging sites you have out there (with the help of SimplePie).

Its not secret, I love social networking, I cant get enough of it. I also love programming and anything internet related. I'm not sure how I came across it, but a PHP based, Object Oriented RSS caching tool named SimplePie caught my attention.

SimplePie offers one piece of functionality that he found particularly useful - the ability to merge RSS feeds easily. He took advantage of the ability and pulled together his Twitter, Flickr, Pownce, Digg and Youtube RSS feeds to make one mega-feed. You can see an example of it in action over on his personal site.

tagged: lifestream simplepie rss feed combine merge tutorial