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

Gonzalo Ayuso:
Handling several PDO Database connections in Symfony2 through the DIC in PHP
Jan 08, 2013 @ 17:52:40

Gonzalo Ayuso has written up a new post about a handling method he's worked up for working with multiple PDO instances (database connections) through the Symfony2 dependency injection container using custom YML definitions and a simple "Db" class.

I’m not a big fan of ORMs, especially in PHP world when all dies at the end of each request. Plain SQL is easy to understand and very powerful. Anyway in PHP we have Doctrine. Doctrine is a amazing project, probably (with permission of Symfony2) the most advanced PHP project, but I normally prefer to work with SQL instead of Doctrine. [...] Due to my daily work I need to connect to different databases (not only one) in my applications.

He shows the normal setup using the "parameters.yml" file to define the multiple database connections but notes that this isn't the most ideal solution. Instead, he walks you through the steps to create the "databases.yml" configuration file and a simple "Db" class that acts as an interface to pull the PDO objects from the container. You can then just call the "get" method on the container to extract the fully configured PDO object, ready for use.

tagged: pdo symfony2 connection tutorial multiple yml database

Link:

ServerGrove Blog:
Error "Cannot find module 'less'" with Symfony2, Assetic and Twitter Bootstrap
Mar 19, 2012 @ 17:36:25

On the ServerGrove blog, there's a quick post with a handy tip for the Symfony2 + Assetic users out there - how to get it to recognize the "less" module.

Unfortunately the Symfony documentation does not provide any details on how to configure Assetic to use LESS. There is a blog post by Dustin Dobervich that gives some pointers, but after following the instructions, Assetic issued the following error: Cannot find module ‘less’. We searched around without much success. After several tries, we nailed the configuration.

It's an easy two-step process: first you be sure you have "npm" (the package manager) installed on your system, then you modify your Symfony app.yml file to point to the Node modules path.

tagged: twitter bootstrap module less css yml setting node module

Link:

Henrik Bjørnskov's Blog:
Travis & Composer sitting in a tree K-I-S-S-I-N-G
Nov 18, 2011 @ 17:03:01

Henrik Bjørnskov has a quick new post today showing how to combine two powerful technologies into a simple, configurable autoload system in a Symfony Travis-CI build with Composer.

To integrate your project with travis the only thing necesarry is to have a .travis.yml file and a working PHPUnit test setup like http://github.com/simplethings/SimpleThingsFormExtraBundle. Where the Tests/vendors.php script is executed before the tests are perfomed. But it would be way cooler to just have Composer handle the autoloading and dependencies.

A sample .travis.yml file is included in the post (also here) as well as instructions for grabbing dependencies and including the autoload process in your application's bootstrap.

tagged: composer travisci build system yml configuration tutorial

Link:

Symfony Blog:
Unit Testing your Models
Oct 09, 2008 @ 15:20:00

Symfony developers out there will be happy to know that, since the release of symfony 1.1, writing unit tests for your models has been made even easier.

Writing unit tests for your Propel or Doctrine model is much more easier as of symfony 1.1. In this tutorial, you will learn some great tips and best practices to write better tests for your models.

The tutorial walks you through the creating of a simple test - evaluating a few criteria for the database contents. The entire thing is contained inside of YML files and is easily run via the sfConfig and integrated Propel functionality.

tagged: unittest model symfony framework yml sfconfig propel

Link:

Dave Dash's Blog:
Dynamically adjusting your page title in symfony
Jul 20, 2007 @ 17:03:00

Dave Dash has posted a quick hit for symfony framework users - how to dynamically adjust your page title at your whim.

A lot of the content on reviewsBy.us and other sites we make using symfony have dynamic content. We try to have our page titles reflect the content by prepending the name of the specific restaurant, document or menu item before the site name.

Their path to the prize is a method, prependTitle that's included in a class (myActions.class.php) and used via it's reference in the application's app.yml file.

tagged: dynamic adjust page title symfony framework yml dynamic adjust page title symfony framework yml

Link:

Dave Dash's Blog:
Dynamically adjusting your page title in symfony
Jul 20, 2007 @ 17:03:00

Dave Dash has posted a quick hit for symfony framework users - how to dynamically adjust your page title at your whim.

A lot of the content on reviewsBy.us and other sites we make using symfony have dynamic content. We try to have our page titles reflect the content by prepending the name of the specific restaurant, document or menu item before the site name.

Their path to the prize is a method, prependTitle that's included in a class (myActions.class.php) and used via it's reference in the application's app.yml file.

tagged: dynamic adjust page title symfony framework yml dynamic adjust page title symfony framework yml

Link:

PHP-Coding-Practices.com:
How Table Migrations In CakePHP 1.2 Can Save Your Life
Jul 03, 2007 @ 19:36:07

On PHP-Coding-Practices.com, Tim Koschuetzki has posted a new tutorial that just might save your life - well, at least the life of your CakePHP application - using table migrations.

Migrations are a wonderful technique to keep your database in sync with your code. When working on a project as a team, migrations can save your life. Please join me and get a quick introduction to migrations in CakePHP and become a happier coder.

He starts by explaining what migrations are (yml files that contain database construction/destruction information), how to execute them in your application, and how to construct your own.

tagged: migration table cakephp database construct destruct yml migration table cakephp database construct destruct yml

Link:

PHP-Coding-Practices.com:
How Table Migrations In CakePHP 1.2 Can Save Your Life
Jul 03, 2007 @ 19:36:07

On PHP-Coding-Practices.com, Tim Koschuetzki has posted a new tutorial that just might save your life - well, at least the life of your CakePHP application - using table migrations.

Migrations are a wonderful technique to keep your database in sync with your code. When working on a project as a team, migrations can save your life. Please join me and get a quick introduction to migrations in CakePHP and become a happier coder.

He starts by explaining what migrations are (yml files that contain database construction/destruction information), how to execute them in your application, and how to construct your own.

tagged: migration table cakephp database construct destruct yml migration table cakephp database construct destruct yml

Link:


Trending Topics: