Building a REST API with Apigility that is built on top of Zend Framework 2 is awesome. I’m also a big fan of Doctrine. So I started with the zf-apigility-skeleton and added the zf-apigility-doctrine vendor.
I created an User API and a Doctrine REST service called “User” with the route “/users[/:userId]“. You can defined fields per REST service. Every field will become an instance of Zend\InputFilter\Input, and together they are specified in a Zend\InputFilter\InputFilter.
The username must be unique, so for the POST (adding a user) /users More >
Today I needed to disable a few options in a status select box when building a Zend Framework application. Luckily this is very easy to do, but you just have to know how.
Make sure you set all available options first:
Below that line you can set an attribute on some options. For example, if you want to disable the first, second, and fith option in the select box:
And you’re done!
This week I wanted to created the folder “application/grids/” to store my grids in. For example the path to the grid is “application/grids/Product.php”. The code inside this PHP file:
You will now get the error “Fatal error: Class ‘Application_Grid_Product’ not found”. The new path must be added to the Zend Autoloader in order to load the required classes. Your bootstrap must look like this:
In Zend Framework you can use the $this->escape() view helper to escape variables to protect your website against XSS attacks.
Unfortunately, there is no possibility to enable this by default so that EVERY variable is escaped by default. It’s a bit odd because some other popular frameworks like Symfony provide this by default. And Symfony 1 was released earlier than Zend Framework, so you’d think it would be picked up, but no
Ofcourse if everything is escaped by default, there are situations were variables were escaped earlier in the application like a form element. But when you More >
In this post I’ll desribe how to configure POEdit for Zend Framework in Ubuntu. However POEdit is cross platform compatible and has the same GUI on Windows and Mac, so for these platforms you can also follow several steps below.
If you don’t have POEdit installed yet, open a terminal and execute:
apt-get install poedit
Now start the application with “Alt + F2″ and type “poeditor” and double click the icon. If you start POEdit for the first time, you’ll see the preferences dialog.
Append ” -L php” to the end of the “Parser command:” text field.
With Zend Framework it’s not possible to define multiple translate sources for one Zend_Translate instance that will be stored in the Zend_Registry. Also if you want to add a logger to Zend_Translate, it’s not possible to do this only in your application.ini. The closest you get is to define all translate settings, than create a bootstrap method and “extend” the settings and add a instance of Zend_Log with a writer there.
But we made it possible at the PiKe project to define all this purely in your application.ini.
You only need the file following file, or just add More >