Blog Spot!


Best Practices for Modern PHP Development

Very nice article for the good practices in php: article

  1. Setup and configuration
    1.1. Keep Current
    1.2. Set sensible defaults
    1.3. Extensions
  2. Use Composer
    2.1. Installing Composer
    2.2. Using Composer
    2.3. Install vs update
    2.4. Autoloading
  3. Follow good design principles
    3.1. SOLID
    3.1.1. S - Single Responsibility Principle
    3.1.2. O - Open Closed Principle
    3.1.3. L - Liskov Substitution Principle
    3.1.3. I - Interface Segregation Principle
    3.1.4. D - Dependency Inversion Principle
  4. Object calisthenics
    4.1. No more than one level of indentation per method
    4.2. Try not to use else
  5. Unit testing
    5.1. Tools
    5.2. Tests are a specification
    5.3. Write your tests first
    5.4. What makes a good unit test
    5.5. When testing is painful

Added on 15.Dec.2014
Tags: php development best-practises

Install xdebug on Ubuntu/Mint

Execute the following commands in your terminal.

Download Xdebug - you will need to follow alternate instructions if you don't have PHP5 working on your machine already.

sudo apt-get install php5-xdebug

The package should modify your INI file for you, but just in case you need to edit it yourself open it up and make the following modification - on Ubuntu its typically at /etc/php5/apache2/php.ini - add the following line.

zend_extension="/usr/lib/php5/20110331/xdebug.so"

That path might be a little different on your system - just make sure its a fully qualified path to the xdebug.so file on your machine. Also remember to comment out any references to the Zend Debugger - you can't run both at the same time.

Now restart Apache.

sudo /etc/init.d/apache2 restart

You may also need want enable html_errors. Search for html_errors in /etc/php5/apache2/php.ini and make sure it is set to On. A restart of Apache is also required.

html_errors = On

Double-check with phpinfo() to make sure that everything is installed properly - you may also want to set configurations for Xdebug in your php.ini file.

Added on 13.Dec.2014
Tags: xdebug php linux

Install PDO - SQLite Driver

sudo apt-get install sqlite php5-sqlite
sudo /etc/init.d/apache2 restart

If your phpinfo() is not showing the pdo_sqlite line (in my case, on my Ubuntu Server), you just need to run the lines above and then you'll be good to go.

Added on 13.Dec.2014
Tags: pdo sqlite php driver

CURL - REST Implementation Test Commands

CURL is AWESOME to do what you want ! It's a simple but effective command line tool : http://curl.haxx.se/

curl -i -X GET <URL>
curl -i -X GET <URL>
curl -i -X DELETE <URL>
curl -i -X POST -H '<headers>' -d '<data>' <URL>
curl -i -X PUT -H '<headers>' -d '<data>' <URL>

9 uses for cURL worth knowing

Added on 12.Dec.2014
Tags: curl rest

Installing Composer

We're assuming that this is a local project, so let's install an instance of Composer just for the current project. Navigate to your project directory and run this:

$ curl -sS https://getcomposer.org/installer | php

Keep in mind that piping any download directly to a script interpreter (sh, ruby, php, etc...) is a security risk, so do read the install code and ensure you're comfortable with it before running any command like this.

For convenience sake (if you prefer typing composer install over php composer.phar install, you can use this command to install a single copy of composer globally:

$ mv composer.phar /usr/local/bin/composer
$ chmod +x composer

You may need to run those with sudo depending on your file permissions.

Added on 11.Dec.2014
Tags: composer php

Search


PHP Libraries


Carbon lib / docs
Idiorm lib / docs
Image Workshop lib / docs
lorenzos/Minixed lib / docs
Parsedown lib / docs
PHP Paginator lib / docs
PHP Redis lib / docs
QrCode lib / docs
Requests lib / docs
Slim lib / docs
Spyc lib / docs
TWIG lib / docs
Upload lib / docs
Validation lib / docs
Zebra Image lib / docs

JS Libraries


AJV lib / docs
BackboneJS lib / docs
Bootstrap Notify lib / docs
C3.js lib / docs
ChartJS lib / docs
FastMD5 lib / docs
HighlightJS lib / docs
jQuery-Storage lib / docs
JS-Cookie lib / docs
Leaflet JS lib / docs
LowDB lib / docs
Marked lib / docs
NeedlyJS lib / docs
ParcelJS lib / docs
RequireJS lib / docs
Swig lib / docs
Toastr lib / docs
Underscore lib / docs
ValidateJS lib / docs
top