Symfony2 from YAML to XML configuration

Actually i was a fan of YAML regarding the configuration files of Symfony2.
This was probably because i was used to it since symfony 1.4 and i also thought its better readable.
Its partly still true, but my Netbeans Editor has some problems with using @ in YAML and this breaks my highlighting.
So the better readability vanished to nirvana.

So i checked out XML configuration. Its also widely used by the community.
Pros and Cons (mostly Pros) you can read in this post by Fabien.

Continue reading “Symfony2 from YAML to XML configuration”

Caching Data in Symfony2

Symfony2 has a great Caching Layer based on its HTTP Cache. But this aims mainly on caching the views.

In some apps however you need to cache data behind the scenes, f.e. responses from API calls or custom objects sets.
Symfony2 itself doesnt have such a functionality on first sight (symfony2 doesnt, but Doctrine, see below) and so I searched for one and first found a bundle which utilize the Zend Cache lib:

This worked well but as discussed here( this adds dependencies to your Symfony2 project. This is actually not necessary since Doctrine/Commons is almost always part of your Symfony2 distribution and the Doctrine/Commons provides a Cache Layer as well.
A very good one, indeed.

So if you need to cache data use Doctrine/Commons.
Continue reading “Caching Data in Symfony2”

[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”

Expeditions in the Cloud

Caution: Scepticism ahead!

So i’d like to share some of my experiences in the cloud since i am still trying to figure out if it its worth for me or if i am better suited with an VPS.
Maybe somebody feels like feedbackin.

I tried PHPFog for PHP and by joyent for node.js.
First i have to admit: yes i only tried the free models and of course they are limited and because its free you cant expect to get it all, right?
Yes and thats true.

With PHPFog i set up an app based on symfony 1.4. After some inital problems due to some bugs on PHPFog side, i got it running.
I really like to mention the kind and immediate chat support by PHPFog. It really made me feel like dealin with humans and not only machines. Big up!
By then everything felt really smooth with git deploy, configurations, mysql setup etc.
But i had to shut down the app again, because there are restrictions to PHP which killed the app like disabling “file_get_contents for remote URLS”, probably only in the free model. But that killed it for me at that point.
So read this carefully before going to cloud:
I guess with dedicated hosting you get more power, sure.

Continue reading “Expeditions in the Cloud”

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”