在windows上使用symfony创建简易的CMS系统(一)
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下配置项目(新建虚拟主机)
- <VirtualHost *:1300>
- DocumentRoot "D:\Work\PHP\cms\web"
- DirectoryIndex index.php
- <Directory "D:\Work\PHP\cms\web">
- AllowOverride All
- Allow from All
- </Directory>
- Alias /sf D:\xampp\php\data\symfony\web\sf
- <Directory "D:\xampp\php\data\symfony\web\sf">
- AllowOverride All
- Allow from All
- </Directory>
- </VirtualHost>
注意:
以上配置需要添加在httpd-vhosts.conf文件中,并在httpd.conf中打开对相应端口的监听。
当然,我们也可以通过修改hosts文件添加相应的域名解析。这里略过( 使用localhost ) 。
重启Apache后,通过访问http://localhost:1300/ 可以看到symfony工程欢迎页面。
从这里开始,我们可以选择一个顺手的IDE打开工程,以便更好的发开项目。
3. 配置并创建数据库
打开工程下config中的databases.yml文件,修改数据库连接的参数。
- # You can find more information about this file on the symfony website:
- # http://www.symfony-project.org/reference/1_4/en/07-Databases
- all:
- doctrine:
- class: sfDoctrineDatabase
- param:
- dsn: mysql:host=localhost;dbname=cms
- username: root
- password: root
定义schema ( cms/config/doctrine/schema.yml )
- Category:
- columns:
- name: string(50)
- description: string(1000)
- Content:
- actAs:
- Timestampable: ~
- columns:
- title: string(255)
- body: clob
- view_count: integer
- recommend_level:
- type: enum
- values: [0, 1, 2]
- default: 2
- category_id: integer
- relations:
- Category:
- local: category_id
- foreign: id
- foreignAlias: Contents
- Comment:
- columns:
- body: clob
- user_id: integer
- content_id: integer
- relations:
- Content:
- local: content_id
- foreign: id
- foreignAlias: Comments
运行如下指令:
>symfony doctrine:build --all
4. 导入测试数据
打开cms/data/fixtures/fixtures.yml文件,输入测试数据
- # # Populate this file with data to be loaded by your ORM's *:data-load task.
- # # You can create multiple files in this directory (i.e. 010_users.yml,
- # # 020_articles.yml, etc) which will be loaded in alphabetical order.
- # #
- # # See documentation for your ORM's *:data-load task for more information.
- #
- # User:
- # fabien:
- # username: fabien
- # password: changeme
- # name: Fabien Potencier
- # email: fabien.potencier@symfony-project.com
- # kris:
- # username: Kris.Wallsmith
- # password: changeme
- # name: Kris Wallsmith
- # email: kris.wallsmith@symfony-project.com
- Category:
- c1:
- name: 巴西
- description: 南美球队
- c2:
- name: 英国
- description: 欧洲球队
- c3:
- name: 加纳
- description: 非洲球队
- Content:
- t1:
- title: 卡卡助攻
- body: ......
- view_count: 6
- recommend_level: 0
- Category: c1
- Comments: [m1, m2]
- t2:
- title: 鲁尼没有大作为
- body: ......
- view_count: 10
- recommend_level: 1
- Category: c2
- Comment:
- m1:
- body: 很赞
- m2:
- 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系统(一)的更多相关文章
- 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 ...
- 在Windows上使用Docker 创建MongoDB 副本集的极简方法(翻译)
这篇博客介绍下在Windows上使用Docker 创建MongoDB 三节点副本集的最简单的方法.以下命令需要Docker for Windows并使用Linux 容器. 1: 为每个节点创建数据卷 ...
- 用dedecms自定义表单创建简易自助预约系统
建站往往需要根据客户的需求来增加相应的功能,比如预约.平时用比较多的是织梦系统,那么如何用dedecms自定义表单创建简易自助预约系统呢? 进入dedecms后台,左侧菜单中依次点击“核心” - 频道 ...
- 【python安装】Windows上安装和创建python开发环境
1. 在 windows10 上安装python开发环境 Linux和Mac OS都自带python环境,但是Windows没有,所以需要自行安装. 第1步:访问 python官网,下载Windows ...
- windows上通过vnc连接虚拟机中linux系统
首先要在虚拟机中安装vnc. 虚拟机的设置中要启用VNC连接. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaHdzc2c=/font/5a6L5L2T/ ...
- 峰回路转:去掉 DbContextPool 后 Windows 上的 .NET Core 版博客表现出色
今天早上,我们修改了博客程序中的1行代码,将 services.AddDbContextPool 改为 services.AddDbContext ,去掉 DbContextPool . 然后奇迹出现 ...
- Windows Azure 上的 Symfony,适用于 PHP 开发者的强大组合
发布于 2014-06-13 作者 陈 忠岳 Symfony 是针对 PHP 开发者的流行开源 Web 应用框架.现在,您可以更轻松地在 Windows Azure 上使用它,这都归功于 Ben ...
- 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 创 ...
- windows上通过secureCRT和putty创建密钥登录
前面介绍了linux的ssh远程登录协议和ssh无password登录方式.这里在windows下通过secureCRT和putty登录linux来看一下详细的密钥创建,配置和登录.也算做个备忘录吧. ...
随机推荐
- CSS3之动画相关
CSS3动画相关的属性:transform,transition,animation. 变形Transform 语法: transform: rotate | scale | skew | trans ...
- Duilib扩展《01》— 双击、右键消息扩展
用过duilib的可能会发现,duilib中有些控件没能很好的区分左键.右键等消息.所以根据实际需要,我们需要进行相关区分处理,或者自行扩展. 一. 左键.右键消息区分 我们以CListUI控件来分析 ...
- linux网卡绑定
- landsat8简介
简介 2013年2月11号,NASA 成功发射了 Landsat 8 卫星,为走过了四十年辉煌岁月的 Landsat 计划重新注入新鲜血液.LandSat- 8上携带有两个主要载荷:OLI和TIRS. ...
- 关于enum的那些事儿
自从当年明月的<明朝的那些事儿>爆红之后,以***那些事儿命名的文章便层出不穷.个人认为,这样的命名通俗但具有吸引力,容易接地气.哈哈,所以我也写了几篇以<***那些事儿>的文 ...
- LINE最新版6.5.0在iOS上的删除信息取证
iOS: 9.3.2版 LINE: 6.5.0版 取出LINE的数据库 Line.sqlite,路径如下所示: 检视删除的信息,发现还有不少残留,虽然都是片段,但拼拼凑凑总还是能有些蛛丝马迹,毕竟,总 ...
- leetcode 83
83. Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such that e ...
- poj2000
为了凑今天的数,大水题.不解释了,说来惭愧. #include <stdio.h> int main(){ int n; int i,cnt,j; int tot; while(~scan ...
- 在vs2005中使用SVN进行版本管理
1.软件准备 VisualSVN-Server-2.5.10.msi SVN服务端 WindowsXP-KB942288-v3-x86.exe XP中安装TortoiseSVNSVN1.8必须 Tor ...
- 用Java实现一个堆排序
堆可以看成是一个完全二叉树,而且非终端节点的值均不大于(不小于)其左右孩子节点的值.堆排序只需要一个记录大小的辅助空间,输出堆顶的值之后需要对堆进行调整建立新堆,找到剩下节点的最大值(最小值),反复执 ...