stream_000

stream_000

学无止境,希望能在这里和大家共同学习

  • 财富值15
  • 威望值0
  • 总积分35

个人信息

  • 关注了
  • 回复了 的回答

    composer安装的确是个大问题,我在初次安装Yii2时使用composer从未成功过,几乎放弃,后来在一个朋友的帮助下,终于是把composer安装给整通了,国内composer方式直接安装Yii2最大的一个问题就是强,使用Composer中国全量镜像(http://www.phpcomposer.com/)不用翻.强就可以成功安装Yii2,这是关键,我给楼主说一说这个是怎么做的:

    //全局安装composer(windows)
    将composer.phar放置到php.exe同一目录下,再编辑一个composer.bat文件,这样就可以直接使用composer安装了,而无需再输入php composer.phar,这样的长格式命令。
    注意:应将php.exe的运行目录事先加入到系统的path环境变量当中去!

    //文件及存放目录
    D:\php\php.exe
    D:\php\composer.phar
    //设置path(追加)
    ;D:\php
    //创建composer.bat文件
    D:\php>echo @php "%~dp0comoser.phar" %*>composer.bat
    //查看composer.bat文件是否已成功创建,能看到后面一行的内容则说明OK
    D:\php>type composer.bat
    @php "%~dp0comoser.phar" %*
    
    //测试一下composer是否可以随处运行了:
    d:\php>cd \www
    d:\www>composer -V
    Composer version 1.0.2 2016-04-21 12:30:18
    //出现上面的composer版本信息说明composer全局安装已经顺利完成!
    
    //Composer中国全量镜像
    http://www.phpcomposer.com/
    
    //将Composer更新站点替换为中国全量镜像(很重要,此步没做以后的都不会成功)
    D:\php>composer config -g repo.packagist composer https://packagist.phpcomposer.com
    
    //到此为止,你就可以使用composer进行Yii2的安装了
    
    //安装fxp/composer-asset-plugin,如果版本不对则会报一堆的错误
    d:\www>composer global require "fxp/composer-asset-plugin:~1.1.1"
    Changed current directory to C:/Users/User/AppData/Roaming/Composer
    ./composer.json has been updated
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing fxp/composer-asset-plugin (v1.1.4)
        Downloading: 100%
    Writing lock file
    Generating autoload files
    
    //安装Ysii2,所有的部件都是Downloading: 100%,最后才会显示安装成功,如果卡在Downloading说是“中国全量镜像”未设置成功。
    d:\www>composer create-project --prefer-dist yiisoft/yii2-app-basic basic
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
      - Installing yiisoft/yii2-composer (2.0.4)
        Downloading: 100%
    
      - Installing bower-asset/jquery (2.2.3)
        Downloading: 100%
    
      - Installing bower-asset/yii2-pjax (v2.0.6)
        Downloading: 100%
    
      - Installing letyii/yii2-rbac-mongodb (dev-master 1f17c4e)
        Cloning 1f17c4ea8e5de189a5c8df668de01e3130995e3e
    
      - Installing swiftmailer/swiftmailer (v5.4.1)
        Downloading: 100%
    
      - Installing yiisoft/yii2-swiftmailer (2.0.5)
        Downloading: 100%
    
      - Installing yiisoft/yii2-mongodb (2.0.4)
        Downloading: 100%
    
      - Installing mdmsoft/yii2-admin (2.6)
        Downloading: 100%
    
      - Installing imagine/imagine (v0.5.0)
        Downloading: 100%
    
      - Installing yiisoft/yii2-imagine (2.0.3)
        Downloading: 100%
    
      - Installing raoul2000/yii2-workflow (1.0.0)
        Downloading: 100%
    
      - Installing yiisoft/yii2-codeception (2.0.5)
        Downloading: 100%
    
      - Installing bower-asset/bootstrap (v3.3.5)
        Downloading: 100%
    
      - Installing yiisoft/yii2-bootstrap (2.0.6)
        Downloading: 100%
    
      - Installing yiisoft/yii2-debug (2.0.6)
        Downloading: 100%
    
      - Installing bower-asset/typeahead.js (v0.11.1)
        Downloading: 100%
    
      - Installing phpspec/php-diff (v1.1.0)
        Downloading: 100%
    
      - Installing yiisoft/yii2-gii (2.0.5)
        Downloading: 100%
    
      - Installing fzaninotto/faker (v1.5.0)
        Downloading: 100%
    
      - Installing yiisoft/yii2-faker (2.0.3)
        Downloading: 100%
    
    Writing lock file
    Generating autoload files
    
    d:\www>
    OK!看看你的Yii2是否已经安装成功!
    
    还有一些composer常用的命令,你可以了解一下:
    //composer更新composer.phar
    d:\www>composer selfupdate
    You are already using composer version 1.0.2 (stable channel).
    //更新缓存
    d:\www>composer clear-cache
    Clearing cache (cache-dir): C:\Users\User\AppData\Local\Composer
    Clearing cache (cache-files-dir): C:\Users\User\AppData\Local\Composer\files
    Clearing cache (cache-repo-dir): C:\Users\User\AppData\Local\Composer\repo
    Cache directory does not exist (cache-vcs-dir):
    All caches cleared.
    d:\www>
    

    祝你成功!
    建议:你的问题太多,最好一个话题只提一个问题,这样大家知道怎么帮你!

    感谢感谢,好久没上这个帐号了

  • 提出了问题
    零基础新手请教一些基础问题
  • 回复了 的评论

    只用xampp不行吗?

    没想到这么快就收到回复了,突然觉得用yii的高手们也是很热情的。
    其实我基础很差,只用xampp配置过环境,以前学习过wordpress。其实我对yii一点都不懂。
    看了几天文档,首先了解到的就是配置环境和安装了。
    目前还是完完全全的门外汉,遇到两个完全想不通的问题,估计是因为没有系统学过php的原因。
    1、安装的时候提到composer,直接下载的安装文件点击安装,一直安装不上,坚持了一天奇迹出现了,居然装好了。搞不明白composer到底是个什么东西,是环境的一部分吗?就是用来处理框架各个部分之间的关系?还有就是安装的时候是要从远程下载或者连接什么东西吗?如果是,那么这个下载或连接的东西是不是一旦停止服务,我的yii应用也就不能运行了,还是说只要我不更新composer我的yii还是正常运作。
    2、yii最后东拼西凑的装好了可以访问到网上教程说的页面了,然后几经折腾数据库也误打误撞的配置好了能登录了。但是完全没有看到后台和其他什么东西。这个框架的东西是完全需要自己添加的吗?如我的文章系统分类,用户分类,后台面板
    菜鸟取经,见笑了。希望大神们能帮我解解惑。

  • 只用xampp不行吗?

试用期 等级规则
35/50
资料完整度
30/100
用户活跃度
0/100

Ta的关注

7

Ta的粉丝

1

Ta的访客

5