Showing posts with label symfony. Show all posts
Showing posts with label symfony. Show all posts

Wednesday, March 23, 2011

New Japanese Symfony 1.4 book has been published!

On March 23, a new Japanese symfony(1.4) book had been published!

In Japan, there are a lot of technological books for PHP. but there was no Japanese symfony book for ver 1.4.
Until now there were two books for ver 1.0.
I had written one of Japanese symfony books for ver 1.0 in 2007. It's 4 years ago! Those who wanted to learn symfony and buy Japanese books always said that they couldn't buy symfony books because it's too old. I think that a lot of Japanese developers would like to buy books as well as read it online. Now People focus on Symfony2 but symfony1.4 is stable and the current Long Term Support release, so symfony 1.4 is used in a lot of projects. It's very important for developers to buy this book.

This book has been written by members of the Japanese Symfony user group. They are specialists who use symfony in Japan. So this book includes a lot of tips in practice. We hope this book helps Japanese developers who learn and understand symfony.

And Fabien and Stefan gave us messages for this book. Thanks a lot!

via: http://books.symfony.gr.jp/14book/index.html (Japanese Only)

Friday, March 11, 2011

How to custmize the error page in Symfony2

We can see the new character, which name I don't know at the error page.

Speaking of the character, there is an unofficial symfony character, which name is "Symfonyan".

Symfonyan is "Symfony" + "Nayn". "Nyan" is Japanese which mean mew. She is pretty :D

So, I tried to change the character to Symfonyan in this error page.

How to customize the error page


At the first, I read the documentation Symfony - How to customize Error Pages. But I could not custmize it! Perhaps the path where we put the customized html is changed in PR7. So I read the source code and I saw the correct path.

So I decided to make an original bundle, "SymfonyanBundle" because of making everyone use it easily.

How to install SymfonyanBundle


the source code of SymfonyanBundle is managed in Github. So you can install it by git command.
$ git clone git://github.com/brtriver/SymfonyanBundle.git src/Acme/SymfonyanBundle

You have to add this bundle in app/AppKernel.php

....
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
    $bundles[] = new Symfony\Bundle\WebConfiguratorBundle\SymfonyWebConfiguratorBundle();
    $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
    $bundles[] = new Acme\SymfonyanBundle\SymfonyanBundle(); // <= addition
}


Confirm by the console. If you can add this bundle, you can see like below.
$ ./app/console
...
symfonyan
:exception-install Change the icon of the exception page to Symfonyan
:welcome-install Change the welcome page to Symfonyan

At the last, you have only to run this command from console. It's very simple and easy!

$ ./app/console symfonyan:exception-install --symlink
$ ./app/console assets:install web --symlink

Result


[404 in development env]

[404 in production env]

cute!

One more thing

You can customize the default welcome page with Symfonyan. It's easy to run the command below.

$ ./app/console symfonyan:welcome-install --symlink
The default page is translated to Japanese, too :)

Friday, February 19, 2010

Try to customize the console script in Symfony2

Yesterday, Symfony Reloaded 2.0 Preview was released.
I have tried to use this by symfony-demo.

Symfony 2 is in marked contrast to symfony 1.x, for example, the amount of the directories in Root is only three: "web", "src" and "cart"! How simple!

I found "console" script in the cart directory. when I ran it with the "--shell" option in my console, "Symfony 2" message was displayed like below:

 
So I tried to customize this "Symfony 2" message to change another one.

Symfony 2 is written in PHP 5.3, so each class has "namespace". I copied the files to change from the Symfony 2 core directory and replaced the namespace below:
// namespace Symfony\Framework\WebBundle\Console; // original
namespace Bundle\CartBundle\Console; // new
 and replaced the use path in the console script, too:
//use Symfony\Framework\WebBundle\Console\Application; // original
use Bundle\CartBundle\Console\Application; // new
 I added an ASCII Art, which is the unofficial charactor of symfony that was born in the Japanese symfony comunity and twitter. Her name is "Symfo-Nyan", she is cute!

You can see the original in this page


OK, after adding the ASCII Art to the message, I ran the console again:




  I saw it is easy to customize Symfony 2 but if you are not used to using "namespace" with PHP, you should learn about it.

Tuesday, February 16, 2010

symfony session storage with using MongoDB

MongoDB is  an open source, scalable, high-performance, schema-free, document-oriented database written in the C++ programming language.((via: wikipedia))

symfony has the file session storage class, PDO session storage class but has no MongoDB session storage class.

So I wrote the symfony session storage class with using MongoDB.
You can use below.
http://github.com/brtriver/sfMongoSessionStorage

As a matter of course I don't think MongoDB is the best solution for session storage but it's faster than MySQL session storage.

configuration

If you use sfMongoSessionStorage class, you configure the factories.yml.

storage:
     class: sfMongoSessionStorage
     param:
       host: localhost          #hostname
       port: 27017              #port number
       db_name: symfony         #DB name
       collection_name: session #collection name

bench mark results

This is the bench mark results on my local machine.
$ ab -n 5000 -c 100 http://localhost/index.php

MySQL   => Requests per second:    10.86 [#/sec] (mean)
MongoDB => Requests per second:    16.61 [#/sec] (mean)

Default => Requests per second:    17.58 [#/sec] (mean)
MongoDB session storage is much faster than MySQL one.