翻译进度
7
分块数量
3
参与人数

安装

这是一篇协同翻译的文章,你可以点击『我来翻译』按钮来参与翻译。


安装

要求

在安装之前,Laravel Nova有一些您需要注意的要求:

  • Composer
  • Laravel Framework 5.6+
  • Laravel Mix
  • Node.js & NPM
michealzh 翻译于 5年前

Installing Nova

Once you have purchased a Nova license, you may download a Nova release from the "releases" section of the Nova website. After downloading a Zip file containing the Nova source code, you will need to install it as a Composer "path" repository within your Laravel application's composer.json file.

First, unzip the contents of the Nova release into a nova directory within your application's root directory. Once you have unzipped and placed the Nova source code within the appropriate directory, you are ready to update your composer.json file. You should add the following configuration to the file:

"repositories": [
    {
        "type": "path",
        "url": "./nova"
    }
],

Hidden Files

When unzipping Nova into your application's nova directory, make sure all of Nova's "hidden" files (such as its .gitignore file) are included.

下一步,在 composer.json 文件中,新增 laravel/novarequire 区块内。

"require": {
    "php": "^7.1.3",
    "fideloper/proxy": "^4.0",
    "laravel/framework": "5.6.*",
    "laravel/nova": "*"
},

紧接着在 terminal 中运行 composer update 来安装 composer.json 中声明的依赖包:

composer update

最后,运行 artisan 命令,运行 nova:installmigrate
其中 nova:install 命令是安装 Nova 服务提供者以及发布静态资源到你的应用目录去。

php artisan nova:install

php artisan migrate
MrCong 翻译于 5年前

After running this command, verify that the App\Providers\NovaServiceProvider was added to the providers array in your app configuration file. If it wasn't, you should add it manually. Of course, if your application does not use the App namespace, you should update the provider class name as needed.

The default App\Nova\User Nova resource references the App\User model. If you place your models in a different directory or namespace, you should adjust this value within the resource:

public static $model = 'App\\Models\\User';

That's it! Next, you may navigate to your application's /nova path in your browser and you should be greeted with the Nova dashboard which includes links to various parts of this documentation.

Package Stability

If you are not able to install Nova into your application because of your minimum-stability setting, consider setting your minimum-stability option to dev and your prefer-stable option to true. This will allow you to install Nova while still preferring stable package releases for your application.

Authorizing Nova

Within your app/Providers/NovaServiceProvider.php file, there is a gate method. This authorization gate controls access to Nova in non-local environments. By default, any user can access the Nova dashboard when the current application environment is local. You are free to modify this gate as needed to restrict access to your Nova installation:

/**
 * Register the Nova gate.
 *
 * This gate determines who can access Nova in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewNova', function ($user) {
        return in_array($user->email, [
            'taylor@laravel.com',
        ]);
    });
}

Updating Nova

To update your Nova installation, you may simply download a release Zip file from the Nova website. After downloading the Zip file, replace the current contents of your application's nova directory with the contents of the Zip file. After updating the directory's contents, you may run the composer update and nova:publish commands:

composer update

php artisan nova:publish

nova:publish 命令会重新发布 Nova 的公共资源、配置,视图和语言文件。此命令不会覆盖现有的配置,视图和语言文件。如果您希望该命令覆盖现有文件,则需要在执行该命令的时候加上 --force 参数:

php artisan nova:publish --force

报告Bug

如果您发现 Laravel Nova 中的 Bug, 请在 Nova issues GitHub 仓库打开一个 issue.

michealzh 翻译于 5年前

本文章首发在 LearnKu.com 网站上。

本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
贡献者:3
讨论数量: 0
发起讨论 只看当前版本


暂无话题~