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

Matthias Noback:
Symfony2 Add a global option to console commands and generate a PID file
November 26, 2013 @ 14:06:11

Cal Evans has pointed out a post by Matthias Noback related to Cal's "Signaling PHP" book and an idea presented in one of the appendices - working with PID files as a global option. Mattias writes:

Recently I read the book Signaling PHP by Cal Evans. It's a short book, yet very affordable and it learned me a couple of things. First of all it explains about how you can "capture" a Ctrl+C on your long-running command and do some necessary cleanup work before actually terminating the application. In the appendix it also mentioned the interesting concept of a PID file. [...] In Appendix A of "Signaling PHP", Cal writes about a way to extend a Symfony command to automatically create such a PID file before executing its task, and to delete this file afterwards.

Mattias shares what he calls a "hack" to make it happen globally - using the eventing system built into the Symfony Console functionality and the "console.command" event. He creates a bundle to help with the reading/writing of the PID file and shows how to implement it as a part of the event handling. He does point out one problem with this method (that the "input" object isn't available) so he works around it with the "ArgvInput" component and some manual handling to grab the PID file location provided.

0 comments voice your opinion now!
symfony2 console option command pid file tutorial bundle

Link: http://php-and-symfony.matthiasnoback.nl/2013/11/symfony2-add-a-global-option-to-console-commands-and-generate-pid-file/

Anthony Ferrara:
Failure Is Always An Option - Programming With Anthony
April 01, 2013 @ 09:03:19

Anthony Ferrara has posted another video in his "Programming with Anthony" series, this time pointing out that failure is always an option.

A few days ago, I posted a video about how to become a better developer. There were a few interesting comments made, but one in particular from the Reddit threadpeaked my interest. So I decided to do a reply.

You can watch the video either in his blog or over on Youtube. He's also included the some of the contents of the Reddit post and a funny (relevant) comic about learning "C++ in 21 days".

0 comments voice your opinion now!
failure option video programming youtube reddit


Christer Edvartsen's Blog:
Running Multiple Versions of PHPUnit
December 05, 2011 @ 12:26:18

Christer Edvartsen has a recent post showing you how to get multiple PHPUnit versions installed and working on your application. There's been some issues lately due to some updates in recent PHPUnit versions:

The latest version of PHPUnit (3.6.4 at the time of this writing) does not play well with the Zend Framework extensions (Zend_Test_PHPUnit). After asking Matthew Weier O'Phinney about this he answered that they had standardized on PHPUnit-3.4 for ZF1. Having just upgraded to the latest version of PHPUnit on our servers we were no longer able to test our Zend Framework applications. One option was to downgrade PHPUnit, but since we were already using some of the new features this was not going to happen.

He method uses the "installroot" option that can be passed in to the PHPUnit installation process to point it to someplace other than the default PEAR install location. A small change is needed to the "phpunit" executable to have it correctly set the include path. Then it's just a matter of making a symlink to your "/usr/bin" directory pointing to the specific version.

0 comments voice your opinion now!
multiple version phpunit unittest installroot option


Brian Swan's Blog:
SQL Server Driver for PHP Connection Options Encrypt & Failover_Partner
March 11, 2011 @ 08:41:11

Brian Swan has posted two more in his "SQL Server Driver for PHP" series looking at some of the connection options that are available. In these two new articles he looks at the Failover_Partner and Encrypt options.

Database mirroring is primarily a software solution for increasing database availability. [...] When a PHP application connects to the primary server, the Failover_Partner connection option specifies the name of the server to which the application should connect if the primary server is not available.

[...] These two options, Encrypt and TrustServerCertificate, are often used together. The Encrypt option is used to specify whether or not the connection to the server is encrypted (the default is false). The TrustServerCertificate option is used to indicate whether the certificate on the SQL Server instance should be trusted (the default is false).

In both there's code examples showing the connection strings and what kinds of parameters you can pass to them. He also gives a few examples of scenarios when they might be useful.

0 comments voice your opinion now!
connect sqlserver driver option failoverpartner encyrpt trustservercertificate


Brian Swan's Blog:
SQL Server Driver for PHP Connection Options CharacterSet
February 28, 2011 @ 12:15:33

Brian Swan has posted another in his series looking at connection options for the SQL Server driver for PHP. In his latest he looks at the "CharacterSet" setting, an easy way to define which encoding the remote database is using.

One thing that helped me understand the CharacterSet option was to realize that its name is a bit misleading (although it seems to be inline with other uses of CharacterSet or charset). It is used to specify the encoding of data that is being sent to the server, not the character set. With that in mind, the possible values for the option begin to make sense: SQLSRV_ENC_CHAR, SQLSRV_ENC_BINARY, and UTF-8.

He looks at each of these three options in more detail - SQLSRV_ENC_CHAR being the default, SQLSRV_ENC_BINARY when binary data is needed and UTF-8 when, obviously, you need UTF-8 data transfer between the client and server.

0 comments voice your opinion now!
sqlserver connection option characterset encoding


Brian Swan's Blog:
SQL Server Driver for PHP Connection Options ReturnDatesAsStrings
February 09, 2011 @ 08:45:28

Brian Swan has a new post to his blog today looking at one of the connection options for the SQL Server driver in PHP - the "ReturnDatesAsStrings" setting that can make handling date and time information simpler for PHP.

This is short post to address a frustration I've seen mentioned on Twitter and in forums a lot: By default, the SQL Server Driver for PHP returns datetime columns as PHP DateTime objects, not strings. This can be especially frustrating if you are not aware of the ReturnDatesAsStrings connection option. By simply setting this option to 1 (or true) when you connect to the server, datetime columns will be returned as strings.

He includes some sample code showing how to use the setting (as a part of the settings array passed in to sqlsrv_connect) and the resulting array key from the fetched results on his sample table. This just gives you one more option for handling dates in your SQL Server-based application, especially if you don't need the full DateTIme object's functionality.

0 comments voice your opinion now!
sqlserver driver connection option return date string datetime


Sameer Borate's Blog:
7 essential php command-line options
December 14, 2009 @ 07:52:38

On his Code Diesel Sameer shares seven essential options you can use to make your command-line PHP experience even better.

Most of us use PHP from a IDE or using a simple text editor with a browser, rarely dropping down to the command-line for running php programs. But php provides some interesting and quick options you can use to perform various common tasks or to debug some nasty installation problems. Below is a list of some useful options you should be familiar with.

Among those on his list, handy options like the ability to define which php.ini file to use (-c), showing what modules are compiled into the current binary (-m) and a syntax highlighted output of the file (-s).

0 comments voice your opinion now!
essential commandline option


Debuggable Blog:
How to Fetch the ENUM Options of a Field - The CakePHP Enumerable Behavior
September 08, 2009 @ 11:47:09

On the Debuggable blog, Tim Koschutzki has added a quick post looking at fetching ENUM options of a database's fields in a CakePHP application.

The field users.level is an enum type and can have the values 'guest', 'user', 'admin', 'superadmin' and 'root'. The problem is that it could be possible that new levels were added in the future. [...] So what I came up with is a very simple behavior that can extract the options for any ENUM field. It uses simple caching in order for the query to not be run all the time, so make sure to clear your cache as you update your enum field options in the db.

His code snippet creates an EnumerableBehavior for the model and grabs the column names from the given table to check the access level for each and write them out to a cache.

0 comments voice your opinion now!
cakephp framework enum option database


PHPMag.ru:
Zend Framework models auto-loading
April 03, 2009 @ 10:25:44

From the PHPMag.ru site comes a recent post looking at a technique for creating auto-loading models in your Zend Framework application.

When it comes to MVC, ZF handles almost everything - your action controllers are triggered, your views are loaded, w/o you having to worry about them. Not the same with models. If you comply to directory layout advised by ZF, you have "models" folder, but framework doesn't interact with it in any way.

There's a three step process he includes to make your models autoload - extend the Zend_Controller_action for the controller you're working with, put loadModel() method into the controller (what will actually load the models) and an optional third step of adding in class autoloading. A few alternatives are also mentioned: Zend_Load_PluginLoader, Zend_Load subclassing and a controller plugin.

1 comment voice your opinion now!
model autoload zendframework tutorial loadmodel plugin option


Jani Hartikainen' Blog:
Database backed Zend_Form elements
March 09, 2009 @ 08:45:27

Jani Hartikainen has a new post that should interest the Zend Framework developers out there - a look at automatically querying the database to fill in the right option values for a Zend_Form element.

It's not very tricky to query a database, and fill a Zend_Form element's possible values from the resultset, but it can be quite boring and extraneous code... We could also create an element which we can give some SQL, and it'll fill itself automatically! This way you can even define database-backed elements in XML or INI configuration files.

He starts with a simple Select element type example and builds from there. He creates a DbSelect layer for the element and with the help of a main method, _performSelect, the script can create a new instance of the CU_Form_Element_DbSelect to pull in the options from the SQL (given in the "dbSelect" parameter).

0 comments voice your opinion now!
database backend select option zendform zendframework query



Community Events





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


deployment release framework api tips library package opinion interview language laravel community introduction update zendserver symfony series podcast list install

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