设置 Yii2 的预览 [英] Setting up preview of Yii2

查看:27
本文介绍了设置 Yii2 的预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Yii2 预览版最近发布,可在 github 上获得.我想试驾一下,但到目前为止的文档"几乎立即过时了,因为它仍在大力开发中.我试图遵循 本指南 使用 Yii2 创建一个简单的 CRUD 应用程序,但在步骤中失败:

The Yii2 preview was recently released and is available on github. I want to take it for a test drive, but the "documentation" so far gets outdated almost instantly since it is still under heavy development. I have tried to follow this guide on creating a simple CRUD app with Yii2, but it fails at the step:

php yiic.php app/create /var/www/yii2

出现错误:

Could not open input file: yiic.php

表示没有名为yiic.php的文件.框架文件夹中唯一的文件夹是yii(framework/yii),并且在该文件夹中没有文件yiic.php,只有Yii.php 在命令行中调用时会给出命令列表:

Indicating that there is no file called yiic.php. The only folder within the framework folder is yii (framework/yii), and within that folder there is no file yiic.php, only Yii.php which when called in the command line gives the command list:

The following commands are available:
- asset
- cache
- help
- message
- migrate

有人成功设置了 Yii2 应用程序吗?愿意分享你是如何做到的吗?

Anyone managed to successfully setup a Yii2 app? Care to share how you got it done?

推荐答案

好像 yiic 现在已经被移除了,不过还有替代方案,所以请继续阅读.

Seems like yiic has been removed for now, there are alternatives though, so read on.

这一切都处于早期阶段,因此以下方法可能会在未来几天/几周/几个月内失效.因此请谨慎使用.

It's all in the early stages, so the following method could break in the coming days/weeks/months. Therefore use with caution.

现在有两种方法可以做到这一点:

There are 2 ways to do this now:

  1. 使用 composer.(我推荐这个选项.)

  1. Use composer. (I recommend this option.)

直接将 yii2/apps/ 目录的内容复制到您的应用程序目录中,具体取决于您要尝试的应用程序类型.

Directly copy the contents of yii2/apps/ directory to your apps directory, depending on the type of app you want to try.

<小时>

目前有 2 个应用类型选项 - 高级和基本.两者都在 yii2/apps/目录中各自的目录中,即 yii2/apps/advancedyii2/apps/basic.

基本通过 basic readme.md,高级通过 高级 readme.md.

For basic go through the basic readme.md, and for advanced go through the advanced readme.md.

  1. 使用 composer 的说明在各自的 readme.md 文件中给出.将它们包括在此处以确保完整性:

  1. The directions for using composer are given in the respective readme.md files. Including them here for completeness:

  • 基本应用:
  1. 安装composer,如果你没有的话.
  2. 使用 composer 安装应用程序和依赖项(Yii):php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial
  3. http://localhost/my_yii2_trial/www 访问应用程序

  • 高级应用:

  • Advanced app:

    1. 安装composer,如果你没有的话.
    2. 使用 composer 安装应用程序和依赖项(Yii):php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-advanced my_yii2_trial
    3. 根据自述文件,在第 2 步之后应用程序应该可以访问,但是 composer 失败了(参见 issue439).使用 schmunk's 提示,运行 installinstall.bat 命令由作曲家复制: ./install .选择的开发环境(通过在运行 install 命令时显示的说明中输入选项 0).
      更新:该命令已重命名为 init,composer 不会再失败了,来自 Qiang 的修复(检查 issue 439 了解更多详情).
    4. 在以下位置访问应用程序:http://localhost/my_yii2_trial/frontend/wwwhttp://localhost/my_yii2_trial/backstage/www

    1. Install composer, if you don't have it.
    2. Use composer to install the app alongwith dependencies(Yii): php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-advanced my_yii2_trial
    3. According to readme, after step 2 app should be accessible, but composer was failing(see issue 439). With schmunk's tip, ran the install or install.bat command that gets copied by composer: ./install . Selected development environment (by entering choice 0 in the instructions that show up when running install command).
      Update: The command has been renamed to init, composer doesn't fail anymore, with fix from Qiang (check the issue 439 for more details).
    4. Access app at: http://localhost/my_yii2_trial/frontend/www or http://localhost/my_yii2_trial/backstage/www

  • 以下是复制目录并使其工作的方法:

    Here's how to copy the directory and get it working:

    • 基本应用:

    • Basic app:

    1. 创建应用程序的网络访问目录:my_yii2_trial
    2. 将所有文件和文件夹从 yii2/apps/basic/ 目录复制到 my_yii2_trial/ 目录.
    3. 修改 my_yii2_trial/www/index.php 文件以指向 Yii.php 的正确路径.对我来说它在 yii2/framework/yii/
    4. comment 试图包含 ../vendor/autoload.php 文件的行,我在任何地方都找不到该文件,所以它可能用于一些未来的用途.它是composer提供的自动加载器.
    5. 访问从浏览器:http://localhost/my_yii2_trial/www

    1. create your web-accessible directory for the app : my_yii2_trial
    2. copy all files and folders from yii2/apps/basic/ directory to my_yii2_trial/ directory.
    3. modify the my_yii2_trial/www/index.php file to point to the correct path for Yii.php. For me it was within yii2/framework/yii/
    4. comment the line that tries to include ../vendor/autoload.php file, I couldn't find that file anywhere, so its probably for some future use. it is the autoloader provided by composer.
    5. Access from browser : http://localhost/my_yii2_trial/www

  • 高级应用:

  • Advanced app:

    1. 创建应用程序的网络访问目录:my_yii2_trial
    2. 将所有文件和文件夹从 yii2/apps/advanced/ 目录复制到 my_yii2_trial/ 目录.
    3. 修改 my_yii2_trial/frontend/www/index.php 文件以指向 Yii.php 的正确路径.同样修改backstage/www/index.php.
    4. 注释试图在 index.php 中包含 ../vendor/autoload.php 文件的行后台前端.
    5. 访问应用程序位于:http://localhost/my_yii2_trial/frontend/wwwhttp://localhost/my_yii2_trial/backstage/www>

    1. create your web-accessible directory for the app : my_yii2_trial
    2. copy all files and folders from yii2/apps/advanced/ directory to my_yii2_trial/ directory.
    3. modify the my_yii2_trial/frontend/www/index.php file to point to the correct path for Yii.php. Similarly modify backstage/www/index.php.
    4. comment the line that tries to include ../vendor/autoload.php file in both the index.php of backstage and frontend.
    5. Access app at: http://localhost/my_yii2_trial/frontend/www or http://localhost/my_yii2_trial/backstage/www

  • <小时>

    阅读更多相关内容的一些重要链接:issue 77issue 108问题 131维基评论.

    我不确定如何使用 Composer 的自动加载器,因此无法对此发表评论.同样在未来的版本中,backstage 可能会重命名为 backend.

    I am not sure how composer's autoloader is being used, so can't comment on that. Also in future versions, backstage might be renamed to backend.

    这篇关于设置 Yii2 的预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆