Install symfony2 and create the first page. The first _ PHP Tutorial for symfony2

Source: Internet
Author: User
Install and create the first page of symfony2. Install and create the first page of symfony2. install and configure symfony21、. see symfony.cndocsbookinstallation.html. install and create the first page of symfony2 in Openyourc symfony2 in windows.

1. installation and configuration

Reference http://symfony.cn/docs/book/installation.html

Use the installation tool:

Windows

Open your command console and execute the following command:

c:\> php -r "readfile('http://symfony.com/installer');" > symfony.phar

Then, move the downloadedsymfony.pharFile to your projects directory and execute it as follows:

c:\> move symfony.phar c:\projectsc:\projects\> php symfony.phar

Create a symfony application:

Once the Symfony Installer is ready, create your first Symfony application withnewCommand:

# Linux, Mac OS X$ symfony new my_project_name# Windowsc:\> cd projects/c:\projects\> php symfony.phar new my_project_name

Run the symfony application:

Symfony leverages the internal web server provided by PHP to run applications while developing them. Therefore, running a Symfony application is a matter of browsing the project directory and executing this command:

$ cd my_project_name/$ php app/console server:run

2. Directory

/App: Cache, configuration file, log, and core configuration parameters exist;

/Bin: stores the execution files used;

/Src: Source code compiled by yourself. view files are placed in the view folder.

/Vendor: stores third-party code;

/Web/app. php: single entry file

Check configuration:

Command line d: \ symfony2.3 \ app> php check. php

Or enter http: // localhost: 8000/config. php in the browser.

3. compile a hello world page

> Php app/console generate: bundle creates a new bundle.

Controller/defacontroller Controller. php

 // The value of $ name is the value of name in route {} return array ('name' => $ name); // return the value of name to view file }}

Default/index.html. twig

Hello {{ name }}!

Enter http: // localhost: 8000/app_dev.php/hi/world in the browser. the Hello world!

Http://www.bkjia.com/PHPjc/1099827.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1099827.htmlTechArticlesymfony2 install and create the first page, symfony2 first 1. install and configure reference http://symfony.cn/docs/book/installation.html use installation tool: windows system Open your c...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.