This project is a base for your Silex applications that needs Perch integration for a truly simple and friendly backend interface.
Silex is a powerful micro-framework for PHP, built on the shoulders of Symfony2. The idea is to use Silex to provide the frontend magic, while you can separate and present the robust Perch backend to your customers.
Start by cloning this repository, and install the dependencies using Composer:
git clone https://github.com/cvaldemar/Silex-Perch.git silex-perch
cd silex-perch
curl -s http://getcomposer.org/installer | php
php composer.phar install
Install a copy of Perch into vendor/perch
:
unzip perch_v1.8.4.zip
mv perch_v1.8.4 silex_perch/vendor/perch
Finally, configure Perch, by creating a vendor/perch/config/config.php
. If you install the backend separately or have it
running already just copy config.php
from that installation. If you are installing a clean Perch make sure
you create the database and database tables using the perch.sql
included with Perch.
Start hacking in src/controllers.php
. Create your Twig views in views/
and use the new Twig
tags to initialize content from the Perch backend.
Example:
{{ perch_runtime() }}
{{ perch_location('/index') }}
<h1>{{ perch_content('Title') }}</h1>
<p>{{ perch_content('Body') }}</p>
Note: You must call perch_runtime to initialize the Perch runtime and perch_location to specify the page location. Perch will use the location to categorize content elements in the backend.
- Develop the Twig integration further
- Make sure Perch apps work
- Figure out how and where to put Perch to avoid having two installations
Perch-Twig integration based on and inspired by Gavin McFarland's twig-perch-extension
Silex is brought to you by Fabien Potencier, the creator of the Symfony framework, and Igor Wiedler.
Licensed under the MIT license.