Laravel 资源生成与崇高文本 3 运行时异常中止



与您一起检查当我尝试将Sublime Text 3与Laravel Artisan 4一起使用以生成资源时,它返回了这些错误当我被问及是否要创建模型时,它返回了这些错误?

你想让我创建一个狗模型吗?[是|否]

[运行时异常] 已中止

生成:资源 [--字段[="..."]] 资源

[在 0.4 秒内完成,退出代码为 1] [cmd: php C:\Users\Kenny\Dropbox\Projects\test\artisan generate:resource dog --fields= 名称:字符串,年龄:整数] [目录: C:\用户\肯尼\保管箱\项目\测试] [路径: C:\程序文件 (x86)\英伟达 Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\程序 文件 (x86)\英特尔\iCLS 客户端\;C:\Program Files\Intel\iCLS 客户\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\程序 文件\英特尔\英特尔(R) 管理引擎组件\DAL;C:\程序 文件\英特尔\英特尔(R) 管理引擎组件\IPT;C:\程序文件 (x86)\英特尔\英特尔(R) 管理引擎组件\DAL;C:\程序文件 (x86)\英特尔\英特尔(R) 管理引擎组件\IPT;C:\程序文件 (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\程序文件 (x86)\英特尔\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Windows 直播\共享;C:\HashiCorp\Vagrant\bin;C:\php;C:\ProgramData\ComposerSetup\bin;C:\程序 文件 (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\程序 Filesodejs\;C:\Users\Kenny\AppData\Roamingpm]

以下是我崇高的安装软件包

{
    "in_process_packages":
    [
    ],
    "installed_dependencies":
    [
        "0_package_control_loader",
        "bz2"
    ],
    "installed_packages":
    [
        "AngularJS",
        "CSS3",
        "HTML-CSS-JS Prettify",
        "Laravel 4 Artisan",
        "Package Control",
        "PhpDoc"
    ]
}

提前感谢您的帮助。

您可以在本地找到名称为 ResourceGeneratorCommand.php 的文件:vendorwaygeneratorssrcWayGeneratorsCommands

并注释所有代码if($this->confirm....)

或者您可以复制所有代码以回复所有代码:

<?php 
namespace WayGeneratorsCommands;
use IlluminateConsoleCommand;
use SymfonyComponentConsoleInputInputOption;
use SymfonyComponentConsoleInputInputArgument;
class ResourceGeneratorCommand extends Command {
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'generate:resource';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate a new resource';
    /**
     * Generate a resource
     *
     * @return mixed
     */
    public function fire()
    {
        $resource = $this->argument('resource');
        $this->callModel($resource);
        $this->callView($resource);
        $this->callController($resource);
        $this->callMigration($resource);
        $this->callSeeder($resource);
        $this->callMigrate();
        // All done!
        $this->info(sprintf(
            "All done! Don't forget to add '%s` to %s." . PHP_EOL,
            "Route::resource('{$this->getTableName($resource)}', '{$this->getControllerName($resource)}');",
            "app/routes.php"
        ));
    }
    /**
     * Get the name for the model
     *
     * @param $resource
     * @return string
     */
    protected function getModelName($resource)
    {
        return ucwords(str_singular(camel_case($resource)));
    }
    /**
     * Get the name for the controller
     *
     * @param $resource
     * @return string
     */
    protected function getControllerName($resource)
    {
        return ucwords(str_plural(camel_case($resource))) . 'Controller';
    }
    /**
     * Get the DB table name
     *
     * @param $resource
     * @return string
     */
    protected function getTableName($resource)
    {
        return str_plural($resource);
    }
    /**
     * Get the name for the migration
     *
     * @param $resource
     * @return string
     */
    protected function getMigrationName($resource)
    {
        return "create_" . str_plural($resource) . "_table";
    }
    /**
     * Call model generator if user confirms
     *
     * @param $resource
     */
    protected function callModel($resource)
    {
        $modelName = $this->getModelName($resource);
        // if ($this->confirm("Do you want me to create a $modelName model? [yes|no]"))
        // {
            $this->call('generate:model', compact('modelName'));
        // }
    }
    /**
     * Call view generator if user confirms
     *
     * @param $resource
     */
    protected function callView($resource)
    {
        $collection = $this->getTableName($resource);
        $modelName = $this->getModelName($resource);
        // if ($this->confirm("Do you want me to create views for this $modelName resource? [yes|no]"))
        // {
            foreach(['index', 'show', 'create', 'edit'] as $viewName)
            {
                $viewName = "{$collection}.{$viewName}";
                $this->call('generate:view', compact('viewName'));
            }
        // }
    }
    /**
     * Call controller generator if user confirms
     *
     * @param $resource
     */
    protected function callController($resource)
    {
        $controllerName = $this->getControllerName($resource);
        // if ($this->confirm("Do you want me to create a $controllerName controller? [yes|no]"))
        // {
            $this->call('generate:controller', compact('controllerName'));
        // }
    }
    /**
     * Call migration generator if user confirms
     *
     * @param $resource
     */
    protected function callMigration($resource)
    {
        $migrationName = $this->getMigrationName($resource);
        // if ($this->confirm("Do you want me to create a '$migrationName' migration and schema for this resource? [yes|no]"))
        // {
            $this->call('generate:migration', [
                'migrationName' => $migrationName,
                '--fields' => $this->option('fields')
            ]);
        // }
    }
    /**
     * Call seeder generator if user confirms
     *
     * @param $resource
     */
    protected function callSeeder($resource)
    {
        $tableName = str_plural($this->getModelName($resource));
        // if ($this->confirm("Would you like a '$tableName' table seeder? [yes|no]"))
        // {
            $this->call('generate:seed', compact('tableName'));
        // }
    }
    /**
     * Migrate database if user confirms
     */
    protected function callMigrate()
    {
        // if ($this->confirm('Do you want to go ahead and migrate the database? [yes|no]')) {
            $this->call('migrate');
            $this->info('Done!');
        // }
    }
    /**
     * Get the console command arguments.
     *
     * @return array
     */
    protected function getArguments()
    {
        return [
            ['resource', InputArgument::REQUIRED, 'Singular resource name']
        ];
    }
    /**
     * Get the console command options.
     *
     * @return array
     */
    protected function getOptions()
    {
        return [
            ['fields', null, InputOption::VALUE_OPTIONAL, 'Fields for the migration']
        ];
    }
}

现在再试一次!希望对您有所帮助!

最新更新