petehouston/xin-artisan

Laravel artisan 的 "xin" 命令。

1.2.0 2016-06-03 15:14 UTC

This package is auto-updated.

Last update: 2024-09-27 22:03:59 UTC


README

Latest Version on Packagist Software License

Xin Logo

Xin,在越南语中意为“需求某物”。现在,你可以在 Laravel Artisan 控制台中直接 xin 某物。

安装

通过 Composer

$ composer require petehouston/xin-artisan

设置

将此行追加到 config/app.php 文件中的 $providers 变量

    'providers' => [
        ...
        Petehouston\Xin\XinServiceProvider::class,
    ]

配置

您需要将 xin 配置文件 xin.php 添加到您的项目中

$ php artisan vendor:publish --provider="Petehouston\Xin\XinServiceProvider" --tag=config

一些可用的配置变量

  • browser.bin:您想使用的浏览器二进制文件的绝对路径。默认情况下,xin 将自动为您查找。

命令列表

以下命令受支持

  • xin:ip:获取 IP 地址。
  • xin:docs:阅读 Laravel 文档。
  • xin:log:与日志文件交互。
  • xin:gist:通过公共 Gist 分享代码。
  • xin:view:创建空的 Blade 视图。

使用方法

请求 IP 地址

获取本地 IP 地址

$ php artisan xin:ip
Local IP address is: 192.168.100.3

获取公网/外部 IP 地址

$ php artisan xin:ip --public
External IP address is: 13.66.202.129

打开 Laravel 文档的部分

列出所有可用的 Laravel 文档部分

$ php artisan xin:docs list

All of Laravel documentation sections are listed below:
+----------------------------+-------------------------+
| Section                    | Key                     |
+----------------------------+-------------------------+
| Release Notes              | releases                |
| Upgrade Guide              | upgrade                 |
| Contribution Guide         | contributions           |
| Installation               | installation            |
| Configuration              | configuration           |
| Homestead                  | homestead               |
| Valet                      | valet                   |
| Basic Task List            | quickstart              |
| Intermediate Task List     | quickstart-intermediate |
| Routing                    | routing                 |
| Middleware                 | middleware              |
| Controllers                | controllers             |
| Requests                   | requests                |
| Responses                  | responses               |
| Views                      | views                   |
| Blade Templates            | blade                   |
| Request Lifecycle          | lifecycle               |
| Application Structure      | structure               |
| Service Providers          | providers               |
| Service Container          | container               |
| Contracts                  | contracts               |
| Facades                    | facades                 |
| Authentication             | authentication          |
| Authorization              | authorization           |
| Artisan Console            | artisan                 |
| Billing                    | billing                 |
| Cache                      | cache                   |
| Collections                | collections             |
| Elixir                     | elixir                  |
| Encryption                 | encryption              |
| Errors & Loggin            | errors                  |
| Events                     | events                  |
| Filesystem & Cloud Storage | filesystem              |
| Hashing                    | hashing                 |
| Helpers                    | helpers                 |
| Localization               | localization            |
| Mail                       | mail                    |
| Package Development        | packages                |
| Pagination                 | pagination              |
| Queues                     | queues                  |
| Redis                      | redis                   |
| Session                    | session                 |
| SSH Tasks                  | envoy                   |
| Task Scheduling            | scheduling              |
| Testing                    | testing                 |
| Validation                 | validation              |
| Database - Getting Started | database                |
| Query Builder              | queries                 |
| Migrations                 | migrations              |
| seeding                    | seeding                 |
| Eloquent - Getting Started | eloquent                |
| Relationships              | eloquent-relationships  |
| Eloquent Collections       | eloquent-collections    |
| Mutators                   | eloquent-mutators       |
| Eloquent Serialization     | eloquent-serialization  |
+----------------------------+-------------------------+

在浏览器中打开部分

Xin 将使用默认的系统浏览器打开 URL。键是来自“列表”的值。

$ php artisan xin:docs read --key=envoy

以不同语言打开文档

使用 --locale 选项。目前仅支持“en”和“vn”。默认为“en”。

$ php artisan xin:docs read --key=structure --locale=vn

与日志文件交互

所有日志都存储在 storage/logs 目录下。

读取日志文件

默认日志文件为 laravel.log

$ php artisan xin:log

您可以按名称读取不同日志文件的内容

$ php artisan xin:log --name=custom.log

清理日志文件内容

$ php artisan xin:log --clean

日志文件将变为空。

您可以组合清理自定义日志文件

$ php artisan xin:log --name=custom.log --clean

删除所有日志

$ php artisan xin:log --remove-all

此命令将删除 storage/logs 目录下的所有文件。

通过 Gist 分享代码

此命令将源文件分享到公共 Gist。它将响应包含 Gist IdGist Url

$ php artisan xin:gist [filename] --desc="Sharing description."

例如,如果您想分享 public/index.php 文件

$ php artisan xin:gist public/index.php --desc="Sharing Laravel index file."
Gist Sharing Information
------------------------------------------------------------------
Gist Id:  37c55c18cd63c34195c22fafbff6fe16
Gist Url: https://gist.github.com/37c55c18cd63c34195c22fafbff6fe16

注意:在 Windows 上,由于路径分隔符是 \,因此您需要将 filename 用双引号 " 括起来,如下所示

$ php artisan xin:gist "public\index.php"

创建空的 Blade 视图

想从命令行快速创建 Blade 视图文件?使用这个

$ php artisan xin:view admin.auth.login

它将在 resources/views/admin/auth 下创建 login.blade.php,它还会创建路径中不存在的任何目录。

显然,在 Linux/Unix/Mac 上,您可以使用 touch

$ mkdir resources/views/admin/auth
$ touch resources/views/admin/auth/login.blade.php

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件