实现command错误信息提示
原理解析:
源码文件: [console\application] 中 $allCommands 存储了所有命令跟控制台传入的命令进行对比
对比方式: 使用php字符相似度函数 (levenshtein), 正则, 常规匹配方式来获取相近提示
=======================================================================
数据库migrations操作分析[生成,防止重复生成,回滚]
获取要执行的文件路径, 执行up里面的代码生成SQL语句
执行完毕SQL后, 将路径插入migrations表, 下次再次执行 migrate 命令, 则进行路劲对比
如果已经存在, 则不执行
回滚操作则相反, 执行up里面的代码down, 删除表并清理migrations数据表中相关信息
执行的源代码文件[Migrator.php]
public function run($paths = [], array $options = [])
{
// Once we grab all of the migration files for the path, we will compare them
// against the migrations that have already been run for this package then
// run each of the outstanding migrations against a database connection.
$files = $this->getMigrationFiles($paths);
$this->requireFiles($migrations = $this->pendingMigrations(
$files, $this->repository->getRan()
));
// Once we have all these migrations that are outstanding we are ready to run
// we will go ahead and run them "up". This will execute each migration as
// an operation against a database. Then we'll return this list of them.
$this->runPending($migrations, $options);
return $migrations;
}
数据验证规则源代码文件
源码的正则很有奇特, 例如: [\pL\pM]+正则来验证 验证字段必须完全由字母构成
文件路径: Illuminate\Validation\Validator
验证规则文件路径: Illuminate\Validation\Concerns\ValidatesAttributes
权限验证源代码文件
文件路径: \vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php
==============================================================================
文章长期更新, 个人学习记录, 如果有错误, 欢迎指正