In this article, I'm going to explain about how to create a Web application with Symfony2 Framework. In my previous article, I have explained about how to "Installing and Configuring Symfony2 framework on Linux Ubuntu OS". In this post we are going to learn the basics of create a web application with Symfony2 Framework.
Create a "Hello World" Web application with Symfony2 Framework:
The implementation of "Hello World" project proved to be relatively simple.
Create a "Hello World" Web application with Symfony2 Framework:
The implementation of "Hello World" project proved to be relatively simple.
- A task consists of a database row and has a name or title.
- A task can be assigned a priority.
- A task has a creator date.
- A task can be marked as completed.
- Index : All tasks are displayed and sorted by priority.
- add : In this action the task is created. After successful validation, the user is returned to the [index] Action.
- edit : In this action, an existing task is edited. After successful validation, the user is returned to the [index] Action.
- delete : Allows an existing task will be deleted.
- markAsDone : Allows an existing task is marked as completed.
- marksAsUndone : Allows an existing task is marked as completed.
Working in XAMPP environment:
To create a Web application with Symfony2 framework, we need to install XAMPP server that is under http://www.apachefriends.org/de/xampp.html. and to download the Symfony2 Framework Click Here.
XAMPP is a development environment it needs to be set-up a new named-vhost: www.testsmfony.local (this is valid for project name).
My new named-vhost is :
<VirtualHost *:80> DocumentRoot "C :/ path / to / project / web" ServerName testsmfony.local ServerAlias www.testsmfony.local <Directory "C :/ path / to / project / web" > Order Allow, Deny Allow from all AllowOverride all </ Directory> </ VirtualHost>
To note here is that the /web directory in Symfony2 folder is specified as the destination. Is a 403 error appears, the xampp apache errors.log file to crawl.
Thus the named vhost also can be used, even in the hosts file of the Windows domain name are marked as local address:
Www.testsmfony.local 127.0.0.1
127.0.0.1 testsmfony.local
After restarting the browser and the server XAMPP, now the changes should have been taken.
If you call now URL:
http://www.testsmfony.local/app_dev.php/demo/hello/User% 20and% 20Scandio% 20Tutorial
on should receive a Proket the example, which is automatically created by Symfony2.
"Hello User Scandio Tutorial!"
You get this message, you have done it, and has a running Symfony2 installed.
Console Configuration
To enjoy the full functionality of Symfony2, you must have the PHP CLI environment in the Windows environment variables are entered. (If you have not registered before then). This is not complicated, the path when calling the PHP CLI can be specified.
To edit the PATH environment variable on Windows 7, you will navigate to: Start -> Control Panel -> System and Security -> System -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> Path . then "Edit ..." and click on the end of the string to specify the path to the current PHP CLI. In my example, this is: "C:\xampp\php". There is the php.exe.
Configuration of the Symfony2 project:
First, the connection to the MySQL database is configured.
For this purpose we consider the /app/config/parameters.ini File:
database_driver = pdo_mysql
DATABASE_HOST = localhost
database_name = scandio_project_testsmfony
database_user = root
database_password =
The configurations should here be adapted to the current system. The database is ONLY for testing purposes as root reachable.
Unfortunately, there is an unprecedented bugs fixed bug in Doctrine 2 to thank for that one in the Doctrine Configs not specify MySQL COLLATE can. This is the default COLLATE use the current database. That means in the default configuration of XAMPP LATIN_1 ... Basically here utf8_general_ci should ALWAYS be used.
To avoid the error, use the following SQL:
CREATE DATABASE scandio_project_testsmfony ` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
An easy approach explained in this video
ReplyDeletehttp://www.youtube.com/watch?v=yhKPM4v6p_k