I recently had to set up a Zend Framework project at a friend’s house and realized how reliant I am on Zend Studio to set up a fresh project. Meet Jara Base – the ZF starter app and my solution to this minor issue. It’s essentially a slightly modified version of the Zend Studio project structure with the following variations/additions:
- Added a test helper to the tests folder.
- Added a static route plugin for handling static site pages.
Usage
- Download and unzip Jara Base (either from GitHub or from here).
- Copy to the library files to the root of your application.
- Set up your virtual host and make the ‘public’ folder the web root (the first part of this post shows how).
- Enjoy!
Adding static pages
Most applications have pages for static content e.g. an about page, a contact page, etc. I prefer my static pages without the controller name and the ‘page’ route removes the need to add the controller name to the url. Jara Base already includes an about page with a corresponding view and this page is accessed with ‘http://www.example.com/about’ rather than ‘http://www.example.com/index/about’.
To add a static page, add an action to the ‘Index’ controller of the ‘Default’ module. Add a corresponding view and the page will be available at ‘http://www.example.com/:action’.
Static routes with the same name as your controller actions are created by default.
To disable static routes, comment out (or delete) the static routes line in the plugins section of the application config file (application.ini).
No related posts.
We hope to really nail this issue with 1.8. Our RAD tools like Zend_Tool will generate a default project structure that is recommended by the ZF team. Of course, it will also work with a custom project structure.
,Wil
I had to add this to Initializer.php on lines 15 – 18 to get jara base app to work out of the box:
ini_set('include_path',
ini_get('include_path') .
PATH_SEPARATOR . APP_ROOT . '/library'
);
This assumes you added the framework to /library/Zend
@Eric, My bad. Thanks for the heads-up.
I have the Zend Framework files in my include path and the Initializer class assumed the files would always be available.
It’s fixed now! I have added the Zend Framework files (version 1.7.6) to the library folder and reworked the bootstrap process to set up the include paths before loading the Initializer class.