創(chuàng)建數(shù)據(jù)遷移錯(cuò)誤集:
創(chuàng)新互聯(lián)建站長(zhǎng)期為上千客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為儋州企業(yè)提供專業(yè)的成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè),儋州網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。
錯(cuò)誤描述1:
[ErrorException] include(F:\phpStudy\WWW\blog\vendor\composer/../../database/migrations/2017_09_06_132637_create_ads_table.php): failed to open stream: No such file or directory
在此錯(cuò)誤之前使用php artisan make:migration create_ads_table命令(命令1)執(zhí)行并創(chuàng)建成功,后來(lái)問(wèn)了與創(chuàng)建數(shù)據(jù)模型一致就想到用php artisan make:model Ad --migration命令(命令2),所以把已有遷移文件及數(shù)據(jù)庫(kù)追蹤數(shù)據(jù)表刪除,在執(zhí)行命令2時(shí)產(chǎn)生錯(cuò)誤。
解決方法:執(zhí)行以下3個(gè)命令
第一步、 php artisan cache:clear //清楚緩存
F:\phpStudy\WWW\blog>php artisan cache:clear Cache cleared successfully.
第二步、composer dump-autoload-o
F:\phpStudy\WWW\blog>composer dump-autoload -o Generating optimized autoload files
第三步、composer update
F:\phpStudy\WWW\blog>composer update Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 0 installs, 22 updates, 0 removals - Updating symfony/css-selector (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/polyfill-mbstring (v1.4.0 => v1.5.0): Loading from cache - Updating symfony/var-dumper (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/routing (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/process (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/http-foundation (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/event-dispatcher (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/debug (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/http-kernel (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/finder (v3.3.5 => v3.3.8): Downloading (100%) - Updating symfony/console (v3.3.5 => v3.3.8): Downloading (100%) - Updating ramsey/uuid (3.6.1 => 3.7.0): Loading from cache - Updating symfony/translation (v3.3.5 => v3.3.8): Downloading (100%) - Updating league/flysystem (1.0.40 => 1.0.41): Loading from cache - Updating laravel/framework (v5.4.30 => v5.4.36): Downloading (100%) - Updating fzaninotto/faker (v1.6.0 => v1.7.1): Loading from cache - Updating nikic/php-parser (v3.0.6 => v3.1.1): Downloading (100%) - Updating psy/psysh (v0.8.10 => v0.8.11): Loading from cache - Updating phpdocumentor/reflection-docblock (3.2.0 => 4.1.1): Downloading (100%) - Updating phpspec/prophecy (v1.7.0 => v1.7.2): Downloading (100%) - Updating phpunit/php-token-stream (1.4.11 => 2.0.1): Downloading (100%) - Updating symfony/yaml (v3.3.5 => v3.3.8): Downloading (100%) Writing lock file Generating optimized autoload files > Illuminate\Foundation\ComposerScripts::postUpdate > php artisan optimize Generating optimized class loader The compiled services file has been removed.
以上三步執(zhí)行完,再次執(zhí)行命令2即可成功創(chuàng)建模型與遷移文件。