windows下通过composer安装YII2框架_第1页
windows下通过composer安装YII2框架_第2页
windows下通过composer安装YII2框架_第3页
windows下通过composer安装YII2框架_第4页
windows下通过composer安装YII2框架_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Windows下通过composer安装Yii2框架目录概 述1一、安装准备:开启php的open_ssl支持1NOTE1:使用wamp里的菜单界面php.ini开启openssl设置不起作用), 需要通过php ini命令找到php.ini文件位置,来开启php_openssl.dll。2二、安装composer22.1 Using the Installer composersetup.exe2NOTE2:解决办法:我的电脑右键环境变量 设置HTTP_PROXY=代理服务器地址;端口32.2、手动下载composer.phar自己配置32.2.1使用php命令行下载32.2.3、生成com

2、poser.bat文件。3三、安装Yii2框架4NOTE3:安装过程中,让你输入github网站的令牌(Token),以去除API速率限制。4Verifying the Installation7四、安装之后,程序初始化8NOTE4:到这里貌似可以,还要执行init 才可以生成一些文件,例如main-local.php8五、保证用户正常使用数据库,执行php yii migrate,在数据库生成user表。10六、apache虚拟主机设置10概 述1、安装wamp之后,要开启php的open_ssl支持。2、在windows安装composer有两种方法,直接下载composer.setup安

3、装器(安装会遇到一些问题,不建议使用)从官网下载composer.phar(推荐使用这个方法安装composer)。3、通过安装好的composer.phar安装Yii2框架。4、安装Yii2框架后,执行init命令5、为了使模板正常使用数据库,执行php yii migrate命令,生成user表。一、安装准备:开启php的open_ssl支持Some settings on your machine make Composer unable to work properly.Make sure that you fix the issues listed below and run thi

4、s script again:The openssl extension is missing, which means that secure HTTPS transfers are impossible.If possible you should enable it or recompile php with -with-opensslNOTE1:使用wamp里的菜单界面php.ini开启openssl设置不起作用), 需要通过php ini命令找到php.ini文件位置,来开启php_openssl.dll。需要使用命令找到php.ini位置,在文本上编辑。C: >php -in

5、iConfiguration File (php.ini) Path: C:WindowsLoaded Configuration File: D:wampbinphpphp5.4.12php.iniScan for additional .ini files in: (none)Additional .ini files parsed: (none) 二、安装composerwindows 安装composer两种方式2.1 Using the Installer composersetup.exe用composersetup.exe 安装composer,如果使用代理服务器遇到如下问题:。

6、Warning: Your internet settings may stop Composer from working.Proxy http:/代理服务器:8080 from Environment Variables failed with errors:Php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 . Failed to open stream: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。出现如下错误;Download failed: file_get

7、_contents(): php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 file_get_contents(/composer.phar): failed to open stream: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 Download failed: file_get_contents(): php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 f

8、ile_get_contents(/composer.phar): failed to open stream: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 Download failed: file_get_contents(): php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 file_get_contents(/composer.phar): failed to open

9、 stream: php_network_getaddresses: getaddrinfo failed: 不知道这样的主机。 The download failed repeatedly, aborting.NOTE2:解决办法:我的电脑右键环境变量 设置HTTP_PROXY=代理服务器地址;端口2.2、手动下载composer.phar自己配置Composer官网/download/从官网下载composer.phar(使用php命令行下载;直接下载保存到项目路径即可),把composer.phar加入到PATH里。Change to a di

10、rectory on your PATH and run the install snippet to download composer.phar:2.2.1使用php命令行下载php -r "readfile('/installer');" | php在命令行执行上面命令。如果不可以,就直接下载另存即可。Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini这里要求php开启o

11、pen_ssl支持2.2.2不使用上面的命令,直接从官网下载到项目的文件夹即可。2.2.3、生成composer.bat文件。Create a new composer.bat file alongside composer.phar:在下载的composer.phar文件同一目录下,生成composer.bat文件。C:bin>echo php "%dp0composer.phar" %*>composer.bat在终端执行上面的命令生成composer.bat文件Add the directory to your PATH environment varia

12、ble if it isn't already.Close your current terminal. Test usage with a new terminal:D:www>composer -VComposer version 1.0.0-alpha11 2015-11-14 16:21:07使用新的命令行窗口,验证composer安装成功。三、安装Yii2框架composer global require "fxp/composer-asset-plugin:1.1.1"执行此命令一次即可,安装模板项目文件之前。composer create-pro

13、ject -prefer-dist yiisoft/yii2-app-basic moreless 使用基础版模板,生成项目文件。composer create-project -prefer-dist yiisoft/yii2-app-advanced moreless使用高级版模板,生成项目文件。moreless是项目名称,可以更改。NOTE3:安装过程中,让你输入github网站的令牌(Token),以去除API速率限制。你需要在官网 Personal access tokens。等待需要20多分钟吧出现如下界面,表示安装成功。Verifying the Installation 

14、82;After installation is done, either configure your web server (see next section) or use built-in PHP web server by running the following console command while in the project web directory:php yii serveNote: By default the HTTP-server will listen to port 8080. However if that port is already in use

15、 or you wish to serve multiple applications this way, you might want to specify what port to use. Just add the -port argument:php yii serve -port=8888You can use your browser to access the installed Yii application with the following URL:http:/localhost/官方文档参考地址执行php yii serve命令http:/localhost:8080/

16、 会看到如下界面:四、安装之后,程序初始化NOTE4:到这里貌似可以,还要执行init 才可以生成一些文件,例如main-local.phpD:wwwmoreless>php initYii Application Initialization Tool v1.0Which environment do you want the application to be initialized in? 0 Development 1 Production Your choice 0-1, or "q" to quit 0 Initialize the application

17、 under 'Development' environment? yes|no y Start initialization . generate backend/config/main-local.php generate backend/config/params-local.php generate backend/web/index-test.php generate backend/web/index.php generate common/config/main-local.php generate common/config/params-local.php g

18、enerate console/config/main-local.php generate console/config/params-local.php generate frontend/config/main-local.php generate frontend/config/params-local.php generate frontend/web/index-test.php generate frontend/web/index.php generate yii generate cookie validation key in backend/config/main-loc

19、al.php generate cookie validation key in frontend/config/main-local.php chmod 0777 backend/runtime chmod 0777 backend/web/assets chmod 0777 frontend/runtime chmod 0777 frontend/web/assets chmod 0755 yii chmod 0755 tests/codeception/bin/yii . initialization completed.在advanced版中,执行之后,更改common/config/

20、main-local.php为自己建立的数据库名。参考官网五、保证用户正常使用数据库,执行php yii migrate,在数据库生成user表。六、apache虚拟主机设置1、由于后面虚拟机中需要用到Rewrite所以先编辑Apache的conf目录下的httpd.conf文件。(可根据实际需要操作)添加mod_rewrite.so模块支持。去掉下列行中前面的#号。LoadModule rewrite_module modules/mod_rewrite.so2、配置apache支持虚拟机。这一步很重要。# Virtual hosts#Include conf/extra/httpd-vho

21、sts.conf找到 上面相关文本,去掉#Include conf/extra/httpd-vhosts.conf前的#。# Virtual hostsInclude conf/extra/httpd-vhosts.conf保存退出。3、编辑conf目录下extra文件夹下的httpd-vhosts.conf。去掉实例配置,添加新有配置。以新浪微博为例,配置文件如下:# Use name-based virtual hosting.#NameVirtualHost *:80< VirtualHost *:80>    #管理员邮箱    ServerAdmin jiangfeng3     #项目根目录       DocumentRoot "D:/htdocs/frame_export"           #域名      ServerName 

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论