学习CakePHP第一季
我想制作简易的php mvc框架,如果我有完全能力能够制作属于自己的mvc框架,但看着自己的时间也许不够了,只能拿cakephp框架能够快速开发web程序,这要对于来说学习cakephp的第一步吧。
-
去CakePHP官网:http://cakephp.org/
-
一边操作小例如一遍看CakePHP文档
-
建立之前要写个composer.json,保证安装CakePHP的成功
以 laravel 项目的 composer.json 配置文件为例:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
}
你可以参考http://pkg.phpcomposer.com/
首先安装composer,例如我的操作系统是mac的话,只要全局方式的安装以下:
mv composer.phar /usr/local/bin/composer
然后建立cakePHP的项目:
php composer.phar create-project --prefer-dist cakephp/app my_app_name
比方说我操作过程的截图:
安装完成了以后,就开启服务器:
然后开启服务器:
bin/cake server
打开谷歌浏览器输入:localhost:8756
说明恭喜你成功安装了CakePHP,哈哈
别忘了,要注意以下啊!
是否确认安装过的PHP intl的存在,如果有的话容易成功安装cake PHP,因为cakePHP要看intl.so
Mac安装intl的方法链接地址:
http://iiiciii.com/index.php/blog/21
学习CakePHP的过程可能有些不准的地方,慢慢来解决小的问题。
如果你有不懂的问题,可以联系我电邮jinzita007@yahoo.com,谢谢你!