Laravel 4如何从项目中删除其文件和记录的资源 [英] Laravel 4 How to delete a resource with its files and records from the project
问题描述
我通过sublime文本插件创建了一个控制器。生成资源 - > Tweets
但后来我想摆脱它,所有的文件和记录,它已经在我的项目创建,所以我做了以下:
I created a controller via the sublime text plugin. Generate resource -> Tweets But later on i wanted to get rid of it and all the files and records it had created on my project so i did the following:
-
已删除:
deleted:
Tweetscontroller.php
views/Tweets folder
models/Tweets.php
create_Tweets_table migration
seeds/TweetsTableSeeder.php
编辑了以下记录:
edited off the records in:
route.php
databaseseeder.php,
运行dump-autoload
run dump-autoload
但是后来当我运行php artisan migrate:refresh时,我在命令行中收到以下错误:
But later when i run "php artisan migrate:refresh" i get the following error on my command line:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'CreateTweetsTable' not found","file":"C:\\xampp\\htdocs\\l4radiate\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Migrations\\Migrator.php","line":301}}
$ b $
Please let me know how i can solve this or any easier way of getting rid of a whole resource.
推荐答案
请告诉我如何解决这个问题,或者任何更简单的方法来摆脱整个资源。创建迁移时,迁移文件的名称保存在数据库中的 migrations
表中。
When creating migrations the name of the migration file gets saved in the migrations
table in the database.
因此,当您第一次生成文件并运行migrate时,迁移文件的名称已保存在表中。
So the first time when you generated the files and run migrate the name of the migration file was saved in the table.
之后,当您手动删除文件并运行 migrate:refresh
时,laravel会尝试读取记录的每个文件该表,所以在你的情况下,它没有找到迁移文件( CreateTweetsTable
),你会得到错误。
Afterwards when you deleted manually the files and ran migrate:refresh
laravel tries to read each file that is recorded in the table, so in your case it doesn't find the migration file (CreateTweetsTable
) and you get the error.
尝试手动删除表中的行(您应该看到tweets表迁移的名称),然后查看是否可以修复它。
Try to delete manually the row (you should see the name of the tweets table migration) in the table and see if that fixes it for you.
这篇关于Laravel 4如何从项目中删除其文件和记录的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!