acacha/llum

Llum(加泰罗尼亚语中的“光”)照亮您的Laravel项目。

2.0.1 2018-05-29 10:58 UTC

README

使用 llum 照亮包来加速您的 Github/Laravel 开发工作流程

asciicast

Total Downloads Latest Stable Version Scrutinizer Code Quality Build Status StyleCI Build Status

现在支持 Laravel 5.4。

另请参阅

安装说明

composer global require "acacha/llum=~1.0"

要求

一些命令使用类似于 GNU sed 和 touch 的 bash 命令。在 Windows 上,您可以使用 CygWin 或参阅 StackOverflow

在 MAC OS 上,使用 GNU sed 代替默认安装的 BSD sed

brew install gnu-sed --with-default-names

命令

init

执行

llum init
Please enter your github username (sergi) ? 
Do you want to use our assistant to obtain token via Github API (Y/n)?Y
Github password?

要配置您的 Bithub 用户并获得与 llum 命令交互的令牌(请参阅下面的 github 命令部分)。此命令创建文件 ~/.llumrc ,示例

~ cat .llumrc 
; Llum configuration file

[github]
username = acacha
token = token_here
token_name = your token name here

您可以通过手动创建此文件并在其中放置您的个人 Github 访问令牌(https://github.com/settings/tokens)来避免提供密码。

Github

重要:需要先执行 llum init 命令才能工作。

github:init

重要:需要先执行 llum init 命令才能工作。

此命令初始化一个 Github 仓库,创建一个初始提交,创建一个 Github 仓库并将本地内容与 Github 仓库同步。执行以下命令

git init
git add .
git commit -a -m "Initial version"
llum github:repo
git pull origin master
git push origin master

示例

$ cd myproject
$ llum github:init
Running command git init...
S'ha inicialitzat un buit dipòsit de Git a /home/sergi/myproject/.git/
Running command git add ....
Running command git commit -a -m "Initial version"...
[master (comissió d'arrel) 563473d] Initial version
 1 file changed, 0 insertions(+), 0 deletions(-)
 ...
Running command llum github:repo...
Repository myproject created
Running command git remote add origin git@github.com:acacha/myproject.git...
Running command git pull origin master...
fatal: Couldn't find remote ref master
Running command git push origin master...
Comptant els objectes: 3, fet.
Escrivint els objectes: 100% (3/3), 216 bytes | 0 bytes/s, fet.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:acacha/myproject.git
 * [new branch]      master -> master

github:repo

重要:需要先执行 llum init 命令才能工作。

创建一个新的 Github 仓库

mkdir && cd newrepo
llum github:repo

这会创建一个名为 {yourgithubusername}/newrepo 的新 Github 仓库(当前文件夹名称被使用)。您可以使用以下方式为仓库提供名称

llum github:repo reponame

boot

执行命令

  • devtools
  • sqlite
  • migrate
  • serve

您就可以开始了!

devtools

安装和配置惊人的调试工具 Laravel DebugbarLaravel-ide-helper

llum devtools

debugbar

您可以使用以下方式仅安装 Laravel Debugbar 开发工具

llum debugbar

idehelper

您可以使用以下方式仅安装 Laravel-ide-helper 开发工具

llum idehelper

sqlite

安装完新的 Laravel 项目后,使用 sqlite 命令激活 sqlite

laravel new larapp
cd larapp
llum sqlite
File database/database.sqlite created successfully
.env file updated successfully

sqlite 就可以使用了

php artisan migrate 
Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table

provider

向 config/app.php 文件中添加提供者

llum provider Acacha\AdminLTETemplateLaravel\Providers\AdminLTETemplateServiceProvider::class

alias

向 config/app.php 文件中添加别名/Facade

llum alias Socialite Laravel\Socialite\Facades\Socialite::class

serve

类似于 php artisan serve,但有一些增强功能

  • 首先尝试使用端口 8000,但如果已被占用(在我的情况下,这经常发生,因为 Laravel homestead 已经启动),然后尝试以下端口号(8001,8002,8003)
  • 如果可用的 sensible-browser 命令,则启动浏览器
llum serve
Running php artisan serve --port=8002
Opening https://:8002 with default browser

migrate

运行 php artisan migrate

llum migrate

Packagist

https://packagist.org.cn/packages/acacha/admin

故障排除

MAC OS 上的 GNU sed

Acacha llum 需要GNU sed才能工作,因此使用以下方法将 BSD sed 替换为 GNU sed

brew install gnu-sed --with-default-names

使用以下方法检查您的 sed 版本

man sed

sed GNU 版本路径是

$ which sed
/usr/local/bin/sed

而不是默认的 BSD sed 路径(默认安装在 MAC OS 上)

/usr/bin/sed

更多信息请参阅 mdbootstrap/adminlte-laravel#58

工作笔记

使用 sed 更新 .env 文件中的值

sed -i '/^MAIL_DRIVER=/s/=.*/=log/' .env

注释数据库条目

sed -i 's/^DB_/#DB_/g' .env

在数据库条目前添加 sqlite

sed 's/.*DB_HOST.*/DB_CONNECTION=sqlite\n&/' .env

Artisan serve 总是工作

$continue = true;
$port = 8000;
do {
    echo "Testing with port: ". $port;
    if (check_port($port)) {
        passthru('php artisan serve --port=' . $port);
        $continue=false;
    }
    $port++;
} while ($continue);

echo "END";
function check_port($port,$host = '127.0.0.1') {
    $fp = @fsockopen($host, $port,$errno, $errstr, 5);
    if (!$fp) {
        return true;
    } else {
        // port is open and available
        return false;
        fclose($fp);
    }
}

使用php preg_replace函数的解决方案

file_put_contents(base_path('.env'), preg_replace("/(MAIL_DRIVER)=(.*)/", "$1=log", file_get_contents(base_path('.env'))));

在config/app.php文件中插入提供商

sed '/.*#llum_providers.*/a \\tBarryvdh\\LaravelIdeHelper\\IdeHelperServiceProvider::class,\n' config/app.php