http://blog.csdn.net/kunshan_shenbin/article/details/7164675

参考自:http://xsymfony.801.cxne.net/forum.php?mod=viewthread&tid=12&rpid=459&page=1

在创建项目之前,首先需要搭建symfony发开环境。http://blog.csdn.net/kunshan_shenbin/article/details/7162243

1. 创建工作目录,生成项目文件

>md cms

>cd cms

>symfony generate:project cms

>symfony generate:app frontend

>symfony generate:app backend

2. Apache下配置项目(新建虚拟主机)

  1. <VirtualHost *:1300>
  2. DocumentRoot "D:\Work\PHP\cms\web"
  3. DirectoryIndex index.php
  4. <Directory "D:\Work\PHP\cms\web">
  5. AllowOverride All
  6. Allow from All
  7. </Directory>
  8. Alias /sf D:\xampp\php\data\symfony\web\sf
  9. <Directory "D:\xampp\php\data\symfony\web\sf">
  10. AllowOverride All
  11. Allow from All
  12. </Directory>
  13. </VirtualHost>

注意:

以上配置需要添加在httpd-vhosts.conf文件中,并在httpd.conf中打开对相应端口的监听。

当然,我们也可以通过修改hosts文件添加相应的域名解析。这里略过( 使用localhost ) 。

重启Apache后,通过访问http://localhost:1300/ 可以看到symfony工程欢迎页面。

从这里开始,我们可以选择一个顺手的IDE打开工程,以便更好的发开项目。

3. 配置并创建数据库

打开工程下config中的databases.yml文件,修改数据库连接的参数。

  1. # You can find more information about this file on the symfony website:
  2. # http://www.symfony-project.org/reference/1_4/en/07-Databases
  3. all:
  4. doctrine:
  5. class: sfDoctrineDatabase
  6. param:
  7. dsn:      mysql:host=localhost;dbname=cms
  8. username: root
  9. password: root

定义schema ( cms/config/doctrine/schema.yml )

  1. Category:
  2. columns:
  3. name: string(50)
  4. description: string(1000)
  5. Content:
  6. actAs:
  7. Timestampable: ~
  8. columns:
  9. title: string(255)
  10. body: clob
  11. view_count: integer
  12. recommend_level:
  13. type: enum
  14. values: [0, 1, 2]
  15. default: 2
  16. category_id: integer
  17. relations:
  18. Category:
  19. local: category_id
  20. foreign: id
  21. foreignAlias: Contents
  22. Comment:
  23. columns:
  24. body: clob
  25. user_id: integer
  26. content_id: integer
  27. relations:
  28. Content:
  29. local: content_id
  30. foreign: id
  31. foreignAlias: Comments

运行如下指令:

>symfony doctrine:build --all

4. 导入测试数据

打开cms/data/fixtures/fixtures.yml文件,输入测试数据

  1. # # Populate this file with data to be loaded by your ORM's *:data-load task.
  2. # # You can create multiple files in this directory (i.e. 010_users.yml,
  3. # # 020_articles.yml, etc) which will be loaded in alphabetical order.
  4. # #
  5. # # See documentation for your ORM's *:data-load task for more information.
  6. #
  7. # User:
  8. #   fabien:
  9. #     username: fabien
  10. #     password: changeme
  11. #     name:     Fabien Potencier
  12. #     email:    fabien.potencier@symfony-project.com
  13. #   kris:
  14. #     username: Kris.Wallsmith
  15. #     password: changeme
  16. #     name:     Kris Wallsmith
  17. #     email:    kris.wallsmith@symfony-project.com
  18. Category:
  19. c1:
  20. name: 巴西
  21. description: 南美球队
  22. c2:
  23. name: 英国
  24. description: 欧洲球队
  25. c3:
  26. name: 加纳
  27. description: 非洲球队
  28. Content:
  29. t1:
  30. title: 卡卡助攻
  31. body: ......
  32. view_count: 6
  33. recommend_level: 0
  34. Category: c1
  35. Comments: [m1, m2]
  36. t2:
  37. title: 鲁尼没有大作为
  38. body: ......
  39. view_count: 10
  40. recommend_level: 1
  41. Category: c2
  42. Comment:
  43. m1:
  44. body: 很赞
  45. m2:
  46. body: 太不尽人意了。

运行如下指令:

> symfony doctrine:data-load

5. 接下来我们开始着手生成后台的管理页面:

>symfony doctrine:generate-admin backend Category

>symfony doctrine:generate-admin backend Content

>symfony doctrine:generate-admin backend Comment

通过如下地址访问页面(开发环境入口)

http://localhost:1300/backend_dev.php/category

http://localhost:1300/backend_dev.php/content

http://localhost:1300/backend_dev.php/comment

然后运行如下指令添加css等样式资源:

>symfony plugin:publish-assets

再次访问后页面会比原来漂亮很多。

在windows上使用symfony创建简易的CMS系统(一)的更多相关文章

  1. 004.Create a web app with ASP.NET Core MVC using Visual Studio on Windows --【在 windows上用VS创建mvc web app】

    Create a web app with ASP.NET Core MVC using Visual Studio on Windows 在 windows上用VS创建mvc web app 201 ...

  2. 在Windows上使用Docker 创建MongoDB 副本集的极简方法(翻译)

    这篇博客介绍下在Windows上使用Docker 创建MongoDB 三节点副本集的最简单的方法.以下命令需要Docker for Windows并使用Linux 容器. 1: 为每个节点创建数据卷 ...

  3. 用dedecms自定义表单创建简易自助预约系统

    建站往往需要根据客户的需求来增加相应的功能,比如预约.平时用比较多的是织梦系统,那么如何用dedecms自定义表单创建简易自助预约系统呢? 进入dedecms后台,左侧菜单中依次点击“核心” - 频道 ...

  4. 【python安装】Windows上安装和创建python开发环境

    1. 在 windows10 上安装python开发环境 Linux和Mac OS都自带python环境,但是Windows没有,所以需要自行安装. 第1步:访问 python官网,下载Windows ...

  5. windows上通过vnc连接虚拟机中linux系统

    首先要在虚拟机中安装vnc. 虚拟机的设置中要启用VNC连接. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHdzc2c=/font/5a6L5L2T/ ...

  6. 峰回路转:去掉 DbContextPool 后 Windows 上的 .NET Core 版博客表现出色

    今天早上,我们修改了博客程序中的1行代码,将 services.AddDbContextPool 改为 services.AddDbContext ,去掉 DbContextPool . 然后奇迹出现 ...

  7. Windows Azure 上的 Symfony,适用于 PHP 开发者的强大组合

     发布于 2014-06-13 作者 陈 忠岳 Symfony 是针对 PHP 开发者的流行开源 Web 应用框架.现在,您可以更轻松地在 Windows Azure 上使用它,这都归功于 Ben ...

  8. 002.Create a web API with ASP.NET Core MVC and Visual Studio for Windows -- 【在windows上用vs与asp.net core mvc 创建一个 web api 程序】

    Create a web API with ASP.NET Core MVC and Visual Studio for Windows 在windows上用vs与asp.net core mvc 创 ...

  9. windows上通过secureCRT和putty创建密钥登录

    前面介绍了linux的ssh远程登录协议和ssh无password登录方式.这里在windows下通过secureCRT和putty登录linux来看一下详细的密钥创建,配置和登录.也算做个备忘录吧. ...

随机推荐

  1. TCP/IP详解学习笔记(13)-- TCP连接的建立与终止

    1.TCP连接的建立            设主机B运行一个服务器进程,它先发出一个被动打开命令,告诉它的TCP要准备接收客户进程的连续请求,然后服务进程就处于听的状态.不断检测是否有客户进程发起连续 ...

  2. WPF学习系列之八(形状,画刷和变换)

    形状,画刷和变换   概述: 在许多用户界面技术中,普通控件和自定义绘图之间具有清晰的区别.通常来说,绘图特性只用于特定的应用程序--如游戏,数据可视化和物理仿真等.而WPF具有一个非常不同的原则.它 ...

  3. cacti yum快速部署

    简述:本来是编译安装的,由于编译过程中库文件关联太多,安装文件一定要有顺序性,报错太多,到了rrdtool这一步说什么都安装不过去了,由于时间问 题,选择了yum安装,对于编译安装,这个要简单多了,她 ...

  4. boost:exception使用实例

    /************************************************************************/ /*功能描述: boost exception使用 ...

  5. vsftp快速配置

    /etc/vsftpd/vsftpd.confanonymous_enable=YESlocal_enable=YESwrite_enable=YESlocal_umask=022dirmessage ...

  6. Linux rename命令

    转载:http://blog.csdn.net/sea_shore/article/details/6102437 1.rename命令批量修改文件名, 其实linux下可以使用别的办法来批量修改文件 ...

  7. ASP.NET MVC5 高级编程 第3章 视图

    参考资料<ASP.NET MVC5 高级编程>第5版 第3章 视图 3.1 视图的作用 视图的职责是向用户提供界面. 不像基于文件的框架,ASP.NET Web Forms 和PHP ,视 ...

  8. ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)

    解决Can't connect to MySQL server on 'localhost'  tomcat连接mysql,大概是c3p0配置和mysql配置都有问题,导致了内存溢出,几天后,mysq ...

  9. IOS中UIKit——UIButton的背景图像无法正常显示的原因

    主要是在将图像引入项目中,没有选择Destination:Copy items if needed一项. 没有选择Destination:Copy items if needed一项,图像只能是以链接 ...

  10. centos6.7下编译安装lnmp

    很多步骤不说明了,请参照本人的centos6.7下编译安装lamp,这次的架构是nginx+php-fpm一台服务器,mysql一台服务器 (1)首先编译安装nginx: 操作命令: yum -y g ...