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

Rob Allen:
Registering Doctrine Type Mappings for standalone migrations
November 18, 2014 @ 10: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.

0 comments voice your opinion now!
register type migration doctrine database tutorial custom mapping

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

Peter Petermann:
Building better project skeletons with Composer
November 06, 2014 @ 11:26:54

Peter Petermann has (re)posted an article he wrote about building better project skeletons with Composer and automate the process to make your life easier.

The more you use modern frameworks and the more modular you build your PHP applications, the more likely you'll use a skeleton (or template) for creating new projects. In fact, most of the better known frameworks provide skeletons for you to bootstrap your application with. Those skeletons are great to get started, but it's very likely you'll have your own stack of composer packages that you integrate in each project after a while. Each skeleton will be slightly different, so you'll likely fork your own. This article is meant to provide you with an understanding on how to build a skeleton that will allow you to automate things as far as possible.

He starts with some of the basics, both in the terminology that will be used in the article and a little bit about projects in Composer. He shows how the Zend Framework 2 project makes uses of a built-in "composer.phar" file to make bootstrapping easier but soon asks how it could be improved. The answer comes in the form of Composer's own "create-project" functionality (with a few additions, like cleanup scripts run after the fact). He then gets into building his own custom skeleton that includes a custom post-create-project cleanup script, templates for static files (README, CHANGELOG, etc) and a basic "composer.json" configuration for the end result.

0 comments voice your opinion now!
tutorial custom project skeleton composer application

Link: http://devedge.wordpress.com/2014/11/05/building-better-project-skeletons-with-composer-2/

Reddit.com:
Would you take a job where you had to use a custom MVC framework?
October 08, 2014 @ 12:57:00

There's an interesting discussion happening in the /r/php subreddit on Reddit.com that asks about taking a job if a custom framework was involved.

i recently got a new job and whilst I'm working my notice period I've been tasked to find my replacement. One of the big questions my boss has is whether a developer would mind taking over a MVC framework I built specifically for the company. (I would explain why we didn't use Laravel / Symfony / Zend etc. but that's a whole post in itself). The framework is conventional and should feel familiar to someone with Laravel experience... But at the end of the day it's totally proprietary. It's built to PHP-FIG standards and would come with full documentation. So, would you have any issues taking the job, or would you be put off?

There's opinions shared that lean both ways, but there seems to be a large majority that strays more heavily into the "no" column. They suggest that, with all of the great and well-developed PHP frameworks already out there, a custom one would probably cause more problems that it solves. While there's plenty of technically oriented comments, there's also a few that are more "high level" looking at the reasoning for taking the job (hint: it's not just about technology) and what the needs/requirements of the business are.

0 comments voice your opinion now!
opinion custom mvc framework work

Link: http://www.reddit.com/r/PHP/comments/2il722/would_you_take_a_job_where_you_had_to_use_a/

SitePoint PHP Blog:
Build your own PHP Framework with Symfony Components
October 03, 2014 @ 09:12:05

On the SitePoint PHP blog today there's a post introducing you to the concept of building a framework with Symfony components, using only the ones you need from the Symfony framework ecosystem to create a customized framework to fit your needs.

You've probably met Symfony in your PHP career - or have at least heard of it. What you may not know is that Symfony is, at its core, composed of separate libraries called components, which can be reused in any PHP application. For example, the popular PHP framework Laravel was developed using several Symfony components we will also be using in this tutorial. The next version of the popular CMS Drupal is also being built on top of some of the main Symfony components. We'll see how to build a minimal PHP framework using these components, and how they can interact to create a basic structure for any web application.

He covers some of the main parts of the framework, how to grab the components that will help with some of the common functionality and integrating them to work together. He uses the HttpFoundation, HttpKernel, Routing and EventDispatcher (along with their own dependencies) to create a simple example that will respond to a few different route requests.

0 comments voice your opinion now!
framework components symfony tutorial introduction custom

Link: http://www.sitepoint.com/build-php-framework-symfony-components/

SitePoint PHP Blog:
How to Install Custom PHP Extensions on Heroku
September 29, 2014 @ 14:24:56

The SitePoint PHP blog has a tutorial posted for the Heroku users out there showing you how to install custom PHP extensions on the service as a part of your deployment. Heroku is a platform-as-a-service hosting provider that allows for flexibility in the architecture of your systems and spin up/tear down to happen easily and on demand.

In this tutorial, we'll learn how to install custom extensions on Heroku. Specifically, we'll be installing Phalcon.

He walks you through creating an account on Heroku first and getting the Heroku toolbelt system installed for your operating system. He then starts in on the Phalcon (a C-based PHP framework) installation including all needed supporting packages/extensions. He uses the PHP buildpack and creates a shell script that is executed when the deployment happens. He includes the commands and configuration to handle the deployment and test the resulting installation.

0 comments voice your opinion now!
heroku tutorial custom extension phalcon deploy paas

Link: http://www.sitepoint.com/install-custom-php-extensions-heroku/

SitePoint PHP Blog:
Data Validation in Laravel - Introduction & Custom Validators
August 12, 2014 @ 13:59:16

The SitePoint PHP blog has posted the first two parts of a new series looking at how to do data validation in Laravel, a popular PHP framework. Laravel comes with a set of included validators that can easily be used to check incoming data. This article series introduces them and the features they can provide.

If an app was a world then data would be its currency. Every app, no matter what its purpose, deals in data. And almost every type of app works with user input, which means it expects some data from users and acts on it accordingly. But that data needs to be validated to make sure it is of correct type and a user (with nefarious intent) is not trying to break or crack into your app. Which, if you are making an application which requires user input, is why you would need to write code to validate that data as well before you do anything with it.

In the first part of the series they start with an example of doing validation the "old way". They reproduce this same validation using the Laravel validators and show how to introduce it as a service to the overall application. Their "RocketCandy" validation service can then handle the same validations and make for a cleaner interface in the calling script. It's refactored even more to include exceptions when the validation fails and the HTML for outputting the error messages thrown. Unit tests are also included to ensure things are working as they should.

In the second part of the series they build on the examples from part one and introduce custom validators. An example of validation around dashes, spaces and alphanumeric data is included (using regular expressions) and how they can be defined as custom validation rules.

0 comments voice your opinion now!
data validation laravel introduction custom validator framework

Link: http://www.sitepoint.com/series/data-validation-in-laravel-the-right-way/

Symfony Blog:
Push it to the limits - Symfony2 for High Performance needs
August 04, 2014 @ 13:51:48

On the Symfony blog today they've posted a use case that talks about Symfony meeting some high performance needs and some of the development that was done to make it happen.

For most people, using full-stack frameworks equals slowing down websites. At Octivi, we think that it depends on correctly choosing the right tools for specific projects. When we were asked to optimize a website for one of our clients, we analyzed their setup from the ground up. The result: migrate them toward Service Oriented Architecture and extract their core-business system as a separate service. In this Case Study, we'll reveal some architecture details of 1 Billion Symfony2 Application. We'll show you the project big-picture then focus on features we really like in Symfony2. Don't worry; we'll also talk about the things that we don't really use.

They start with some of the business requirements they needed to meet and how it influenced the overall architecture of the application. They cover some of the things they liked the most about using the framework including bundles and using the EventDispatcher component. Some example code is also included for the custom handling they created for routing, CLI commands and request handling. There's also a mention of using the Profiler, Stopwatch and Monolog trio to do some performance analysis on the resulting application. Finally, there's a brief mention of some of the tools they're not using and why (two of them): Doctrine and Twig.

0 comments voice your opinion now!
symfony usecase performance need application custom

Link: http://symfony.com/blog/push-it-to-the-limits-symfony2-for-high-performance-needs

Master Zend Framework:
Creating Custom ZFTool Diagnostic Classes
May 21, 2014 @ 11:23:59

Continuing on from his previous post introducing you to the ZFTool for Zend Framework 2 applications, Matthew Setter has posted part two of the series focusing on the creation of custom diagnostic classes for the tool.

In this week's tutorial, we're going to see how to step beyond the in-built classes and write our own custom checks. Specifically, we're going to write a check which runs php lint on the module's config file, module.config.php. The reason for doing this is because this file is so important in the configuration of a ZF2 module, that we should have a helpful sanity check for it.

He starts by helping you get all the needed dependencies in place, the ZFTool and ZendDiagnostics modules, installed via Composer. He includes code to help get started on the new diagnostic class and accompanying files. He implements some required methods from an interface, and shows how to enable its checking and define the configuration file. He includes a screenshot of the output so you can ensure things are working as they should be.

0 comments voice your opinion now!
zendframework2 zftool custom diagnostic class tutorial

Link: http://www.masterzendframework.com/zftool-2/creating-a-custom-zftool-diagnostic-class

PHPClasses.org:
Speedup Your Web Deployments Using Composer to Install PHP Classes Packages
December 12, 2013 @ 11:43:01

On the PHPClasses.org site today Manuel Lemos has a new post showing how you can use Composer in your deployments to help install packages from the PHPClasses site.

You can install one or more packages from PHP Classes, JS Classes or other Composer repository sites. [...] To make it simpler for you, PHP Classes and JS Classes generate a sample composer.json file for each package available in the Composer repository. Just go in the page of the package you want to install and click on the Install with Composer link.

He includes a brief guide on installing Composer and an example of the resulting "composer.json" file when you click on a link in a package. He points out the use of logins (depends on the package maintainer) and the use of an "auth.json" to automatically provide this information.

This is a great example of how a site that puts the Composer ecosystem to work to provide packages outside of Packagist. Composer, by default, relies on Packagist for its package information, but you can provide alternate repositories too - including using something like Satis for local packages.

0 comments voice your opinion now!
phpclasses composer install repository custom

Link: http://www.phpclasses.org/blog/post/221-Speedup-Your-Web-Deployments-Using-Composer-to-Install-PHP-Classes-Packages.html

Chris Hartjes:
Testing Listeners
September 30, 2013 @ 11:56:39

In the latest post to his site, Chris Hartjes offers some advice about unit testing with listeners to help teach PHP developers the right way to test.

I had an idea to put together some kind of "PHP Testing Koans" site as a way to help PHP developers get better at learning how to actually write tests. Most developers who are introduced to testing get blocked at the point of actually writing a test. [...] So I started to brainstorm ways to make it happen. With some help from Joel Clermont I stumbled upon using test listeners for this.

He uses the built-in test listeners for PHPUnit to write a system that checks to ensure a certain test exists in a "Koan1Listener" class. This class implements the PHPUnit_Framework_TestListener interface and has several methods to catch events and handle issues thrown during execution.

The approach is simple: for each test class that gets executed, add the names of all the methods to an internal list. When the entire test suite is finished, we then check to see if the test names that we were expecting are in our list of methods we found. I am sure there is a more efficient way to do it, so let me know in the comments of a different approach.
0 comments voice your opinion now!
unittest testing listener custom phpunit koans

Link: http://www.littlehart.net/atthekeyboard/2013/09/27/test-listeners/


Community Events





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


install podcast update library introduction tool language series symfony framework composer laravel interview security community package version opinion voicesoftheelephpant release

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