This section provides an overview of what symfony3 is, and why a developer might want to use it.
It should also mention any large subjects within symfony3, and link out to the related topics. Since the Documentation for symfony3 is new, you may need to create initial versions of those related topics.
Version | Release Date |
---|---|
3.0.0 | 2015-11-30 |
3.1.0 | 2016-05-30 |
3.2.0 | 2016-11-30 |
3.2.5 | 2017-03-09 |
3.2.6 | 2017-03-10 |
3.2.7 | 2017-04-05 |
The installer requires PHP 5.4 or higher. If you still use the legacy PHP 5.3 version, you cannot use the Symfony Installer. Read the Creating Symfony Applications without the Installer section to learn how to proceed. - source: http://symfony.com/doc/current/book/installation.html
Open your command console and execute the following commands:
$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony
You must add php to your path environment variable. Follow theses steps :
Windows 7 :
C:\Program Files\PHP
)Windows 8 & 10
C:\Program Files\PHP
)After this, open your command console and execute the following command:
c:\> php -r "readfile('https://symfony.com/installer');" > symfony
Then, move the downloaded symfony file to your project's directory and execute it as follows:
c:\> move symfony c:\projects
c:\projects\> php symfony
Once the Symfony Installer is available, create your first Symfony application with the new command:
# Linux, Mac OS X
$ symfony new my_project_name
# Windows
c:\> cd projects/
c:\projects\> php symfony new my_project_name
This command can be run from anywhere, not necessarily from the htdocs
folder.
This command creates a new directory called my_project_name/
that contains a fresh new project based on the most recent stable Symfony version available. In addition, the installer checks if your system meets the technical requirements to execute Symfony applications. If not, you'll see the list of changes needed to meet those requirements.
In case your project needs to be based on a specific Symfony version, use the optional second argument of the new command:
# use the most recent version in any Symfony branch
$ symfony new my_project_name 2.8
$ symfony new my_project_name 3.1
# use a specific Symfony version
$ symfony new my_project_name 2.8.1
$ symfony new my_project_name 3.0.2
# use a beta or RC version (useful for testing new Symfony versions)
$ symfony new my_project 3.0.0-BETA1
$ symfony new my_project 3.1.0-RC1
The installer also supports a special version called lts which installs the most recent Symfony LTS version available:
$ symfony new my_project_name lts
Read the Symfony Release process to better understand why there are several Symfony versions and which one to use for your projects.
You can also create symfony applications without the installer, but it was not an good idea. If you want anyway, follow the original tutorial on this link:
Oficial Symfony Docs, Configuring Symfony without the installer
Before continuing, make sure you've read the Installation chapter and can access your new Symfony app in the browser.
Suppose you want to create a page - /lucky/number - that generates a lucky (well, random) number and prints it. To do that, create a "Controller class" and a "controller" method inside of it that will be executed when someone goes to /lucky/number
// src/AppBundle/Controller/LuckyController.php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Response; class LuckyController { /** * @Route("/lucky/number") */ public function numberAction() { $number = rand(0, 100); return new Response( '<html><body>Lucky number: '.$number.'</body></html>' ); } }
<?php
// src/AppBundle/Controller/MyController.php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
class MyController
{
/**
* @Route("/hello")
*/
public function myHelloAction()
{
return new Response(
'<html><body>
I\'m the response for request <b>/hello</b>
</body></html>'
);
}
}