symfony2 安装并创建第一个页面,symfony2第一个1、安装和配置
参考 http://symfony.cn/docs/book/installation.html
使用安装工具:
windows系统
open your command console and execute the following command:
c:\> php -r readfile('http://symfony.com/installer'); > symfony.phar
then, move the downloaded symfony.phar file to your projects directory and execute it as follows:
c:\> move symfony.phar c:\projectsc:\projects\> php symfony.phar
创建symfony应用:
once the symfony installer is ready, create your first symfony application with the new command:
# linux, mac os x$ symfony new my_project_name# windowsc:\> cd projects/c:\projects\> php symfony.phar new my_project_name
运行symfony应用:
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、目录
/app:存在缓存、配置文件、日志及核心配置参数;
/bin:存放用到的执行文件;
/src:自己编写的源代码;视图文件放在view文件夹下
/vendor:存放第三方代码;
/web/app.php:单一入口文件
检查配置:
命令行 d:\symfony2.3\app>php check.php或 浏览器输入http://localhost:8000/config.php
3、编写一个hello world页面
>php app/console generate:bundle 创建一个新的bundle
controller/defaultcontroller.php
$name);//返回name的值给视图文件 }}
default/index.html.twig
hello {{ name }}!
浏览器中输入http://localhost:8000/app_dev.php/hi/world,页面中可以打印出hello world!
http://www.bkjia.com/phpjc/1099827.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1099827.htmltecharticlesymfony2 安装并创建第一个页面,symfony2第一个 1、安装和配置 参考 http://symfony.cn/docs/book/installation.html 使用安装工具: windows系统 open your c...