Superleansilexplate Update v3

Some news from the Superleansilexplate:

  • v3 now uses symfony3 components
    Silex 1.3 supports symfony3 so lets use it :)
    Note: as symfony3 doesnt support php5.4 anymore, we dont either!
  • new ConsoleServiceProvider
    the one from knplabs that was used before seems to be unmaintained and wasnt matching the dependencies anymore.
    So i decided to take it over and renew it a bit. Check it out!
  • Docker support
    I started to use Docker as dev enviroment for my projects, so i added dev & prod Docker support.
    For the sake of simplicity it uses a single container with Apache and PHP7.
    If you have Docker and docker-compose on your machine just spin it up with docker-compose up and check on localhost:8088.

Continue reading “Superleansilexplate Update v3”

Enable Twig-Extensions in Silex revisited

As of 2014 things have changed improved a lot in the Symfony / Silex world, compared to 2011, when i first blogged about twig extensions in Silex.
Things got more easy, yay!

As Composer appeared, installation and autoloading is a breeze nowadays.
I presume here, that you have installed your Silex project via composer.
If so, you can install the twig extensions like this:
Continue reading “Enable Twig-Extensions in Silex revisited”

[Symfony 2][Assetic] Sass, CompassFilter + Foundation Responsive Front-end Framework

Did you ever wonder how to enable 3rd party plugins (or so called “frameworks“) within the great compass toolset managed by assetic in your edgy symfony 2.1 project?

(If there is more extensive documentation available concerning assetic + CompassFilter, please stop reading on and let me know!)

If you take a look at the filter class itself (it is CompassFilter in the generic Assetic\Filter namespace), you should recognise several option values that you can use in your application wide config.yml file.

But first you have to install the framework plugin following these instructions.

Continue reading “[Symfony 2][Assetic] Sass, CompassFilter + Foundation Responsive Front-end Framework”

[Symfony 2] composer.json for a assumed-stable symfony 2 distribution

This small composer.json file is used in a project i am working on atm, feel free to use it at own risk. I will provide non-periodical updates and hopefully soon a full upgrade to symfony 2.1.x including doctrine orm 2.2.x.

I still did not get the point regarding dependency resolution, so i simply “composed” the composer file by writing down my own requirements (“i want only the hottest, newest stuff!!”, then tracked down the error messages, removing them by explicetly writing down the missing dependencies by using the latest “dev-*” versions. After that i tried to run the project, which actually did not work, but selective downgrade of some of the bundles (framework, security-extra blahblah) finally did the job. Continue reading “[Symfony 2] composer.json for a assumed-stable symfony 2 distribution”

Silex and MongoDB simply

Using MongoDB in your Silex Project is quite easy.

I will show this with my Superleansilexplate and will integrate it there as an example.
Since i dont want to integrate MongoDB in Superleansilexplate it will just become an additional gist.

Given you have some smaller amount of data like a counter that needs to be stored or other loose coupled datasets, we simply speak to MongoDB “directly” and store the data via Doctrine MongoDB Abstraction Layer.
Since i presume the Data / Document Structure isnt that complex we dont use Doctrine MongoDB ODM (the Object Document Mapper).
If you want to use it instead, try this Silex Extensions.

Continue reading “Silex and MongoDB simply”

Silex and the HTTP_CACHE

The HTTP_CACHE resp. the reverse proxy of Symfony is a pretty cool thing.
And as it is build-in Silex it can speed up the already fast micro framework massivly,
wich is good for me, as i am mainly workin with Silex right now.

To enable it you have to register it first like its shown in the docs:

$app->register(new Silex\Provider\HttpCacheServiceProvider(), array(
'http_cache.cache_dir' => __DIR__.'/cache/',
));

Also provide the writable cache dir.
Continue reading “Silex and the HTTP_CACHE”

Enable Twig-Extensions in Silex

UPDATE
Please have look here for a updated version.


Note: its about Twig-extensions not about the former “Silex Twig Extension”, this now called TwigServiceProvider.

First fetch the Twig-extensions code and put them in your vendor dir:

git submodule add git://github.com/fabpot/Twig-extensions.git vendor/Twig-extensions/fabpot
git submodule init
git submodule update

Then register the autoloader by using registerPrefixes:

$app['autoloader']->registerPrefixes(array(
'Twig_Extensions_'  => array(__DIR__.'/../vendor/Twig-extensions/fabpot/lib')));

Continue reading “Enable Twig-Extensions in Silex”

Silex Starter Stubs

There are several preconfigured Silex Apps on github. They let you start your Silex project in no time, which is good.
This makes Silex an even more simple rabbithole into the symfony2 world.

I started one myself and had a close look on the others, so i thought i share this.
They all differ a bit so you must choose what fits your needs the best.

They all follow some kind of “best practise” structure, some more, some less.

Continue reading “Silex Starter Stubs”

Silex, Twig und HTML5 BoilerPlate

Alright, there is a bundle for H5BP for symfony2 and there is Assetic, you can probably use both with Silex and thats just fine.
But in case you want to keep your Silex project lean (since its micro) you can use Twig and H5BP only and build / deploy your app from the outside.

With a little tuning of the H5BP build, of course / unfortunatly. (Ok thats the caveat)

So i have a structure like so:
web/
(this is the webroot, here is js/css/images, all that asset stuff and the index, here we use the recommended H5BP stuff’n’structure)
views/
(this is outside of webroot and here are all of the *.twig)
Continue reading “Silex, Twig und HTML5 BoilerPlate”