Skip to main content

Blog

48 posts about PHP

Web security: XSS

XSS is one of the most common security issues we have to worry about. It can be simple to prevent it but sometimes it's not. We must pay attention not only on our PHP code but even on HTML and Javascript ocde without forgetting old browsers. Some malicious users can use old version of Internet Explorer to explore the DOM and... [...]

Becoming a Zend PHP engineer

I have finally passed the test for the Zend PHP certification. The exam consists in 70 questions and you will have 90 minutes. You have to answer right at least to 70% of them (49 questions). You need to buy the voucher from the official Zend website and, optionally, the Zend Study Guide for PHP 5.5. Be sure to select and b... [...]

Setting a LAMP enviroment on Linux

Yet another tutorial about installing a LAMP on Linux (I'm using Ubuntu). I've found all info I needed online but for it wasn't so easy. All informations are different, for different tools and purposes and you can't find them in single tutorial. Here I'm listing all commands we need to set up a good PHP devel... [...]

PHPStorm and PHPUnit autocomplete

To work with PHPUnit without autocomplete is almost impossible and sometimes PHPStorm doesn't show it. We must ensure we have enabled the IDE to see where PHPUnit is installed. I use the phar file. Since when  they have removed the PEAR installation, we have to install PHPUnit with the phar file. So download the phar fi... [...]

Symfony2 best practice

Ok this year Symfony3 will be launched but in the best practice book there are some good recommendations and warning for the next future. I'll try to summarize the most interesting concepts and warnings. There are a lot hints about what you can or must do and some warning about common mistakes and what you must not do.... [...]

Symfony2 best practice

Ok this year Symfony3 will be launched but in the best practice book there are some good recommendations and warning for the next future. I'll try to summarize the most interesting concepts and warnings. There are a lot hints about what you can or must do and some warning about common mistakes and what you must not do.... [...]

Zend2 vs Symfony2. Pro and cons

Zend2 and Symfony2 are the most popular and probably the best PHP framework. YII is a good alternative and there are other good choices like Fuel PHP or Phalcon. But I love these 2 frameworks. Let's see a comparison Zend framework 2 Pro Strong core Good community Support for various database systems and servi... [...]

Doctrine custom repository on Symfony2

Here I am with the first post of the 2015. Happy new year! I'm still learning and working with Symfony2 and today I've had some problem about setting a custom repository class that extends a Doctrine entity. Here is the specific page and paragraph on the offcial documentation. They Symfony documentation is great, much be... [...]

Generate PDF documents using ZF2 and DOMPDF

If you are searching a library to generate PDF documents using Zend framework 2 in PHP, I suggest DOMPDF. You can integrate it with the framework and easily convert HTML documents to PDF. This is very useful if you have some data into your MySQL database and you want to create reports and documents. Just create a simple web pag... [...]

Symfony 2 and Doctrine

If y0u have a database, probably you need to generate entities automatically. We'll use the console on app\console. But there are other small tricks you have to know. Let's see some very useful commands: MySQL enum Using basic Doctrine commands you can have an error about enum types. It's highly recommende... [...]

Writing a Doctrine custom function

Unfortunately Doctrine does not support so many SQL function so you have to build a class to let him use a custom function. Let's start building a DATE_FORMAT function. Let's write the class: namespace Application\Model\Doctrine\Functions; use Doctrine\ORM\Query\Lexer; use Doctrine\ORM\Query\AST\Functions\Functi... [...]

Deploy a Symfony 2 app on a shared hosting

Move all the contents of the directory called web on the root of the Symfony2 project Rename app_dev.php in your index.php Edit the .htaccess file replacing all app_dev.php with index.php Edit your index.php simply updating the require_once paths to let it include the files on the right paths: <?php... [...]

Zend Framework 2 tips and tricks

Zend Framework 2 is becoming the most popular PHP framework. I'm using it every day since a couple of months and I still have many difficulties to build my own and simple web application. The learning curve is very steep and you have to handle a large amount of code. But it has a large community, strong MVC implementation, l... [...]

Zend2 and Doctrine2 tricks

I am trying to work hard with Zend framework and taking advantage using a powerful ORM like Doctrine2. I have many difficulties but after many research and coding, I've gathered some useful tricks and links. Generate entities from database Your application must be connected to the database and you must set the doctrine... [...]

Zend Framework 2 and PHPUnit

Modules are the most exciting news on ZF2. All files seem to be organized and the core structure on your application is more clear. Unit Test on the Skeleton Application First of all download and install the skeleton application using composer or download the zip file. There are some different way to download Zend2 + Skele... [...]

PHP coding standards

PHP is flexible, too much flexible! It hasn't specific variables types. And you have to pay attention to handling a workflow, especially if you are working with sessions, cookies, forms, and many other features. A coding standard in PHP is necessary anyway. Here we have specific ways about how to organize your code. Let... [...]

Symfony2, working with Doctrine entities

Let's see some commands and snippet to interact with Doctrine2. If you use Netbeans IDE, you'll see how easy is to call the entityManager and other objects of this ORM. But remember to put all queries on your model and keep the controller functions as clean as you can. Enum annotation Doctrine is integrated with Sy... [...]

Symfony2, working with Doctrine entities

Let's see some commands and snippet to interact with Doctrine2. If you use Netbeans IDE, you'll see how easy is to call the entityManager and other objects of this ORM. But remember to put all queries on your model and keep the controller functions as clean as you can. Enum annotation Doctrine is integrated with Sy... [...]

What's new on Zend framework 2

As you know Zend 2 is very different from the first version. Let's start with this amazing answer on StackOverflow. Architecture ZF1 is based on MVC , ZF2 is based on MOVE. Huge difference. MOVE = Model Operations Views Events , MVC = Models Views Controllers. Models: it contains the application status and its inf... [...]

PHP 7.0 new features

Rasmus Lerdorf has revealed all the new features during a preview before the launch of PHP 7: check out this slide. I'm having a lot of problems to switch from a PHP 5.6 installation on Ubuntu or Kali Linux. Even PHPBrew is not helping me so I accept any hints and solutions. But let's see how we can install PHP 7. F... [...]