使用sublime文本生成Laravel资源3 RuntimeException已中止

时间:2015-01-09 02:50:15

标签: laravel laravel-4 sublimetext3 artisan

当我尝试使用Subraime Text 3和Laravel Artisan 4来生成资源时,

想与您核实是什么问题当我被问到是否要创建模型时它会返回这些错误吗?

  

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

     

[RuntimeException]已中止

     

生成:资源[--fields [=" ..."]]资源

     

[退出代码1完成0.4秒] [cmd:php   C:\ Users \ Kenny \ Dropbox \ Projects \ test \ artisan generate:resource dog   --fields = name:string,age:integer] [dir:C:\ Users \ Kenny \ Dropbox \ Projects \ test] [路径:C:\ Program Files   (86)\ NVIDIA   公司\ PhysX物理\常见; C:\ ProgramData \ ORACLE \的Java \ javapath; C:\ PROGRAM   文件(x86)\ Intel \ iCLS Client \; C:\ Program Files \ Intel \ iCLS   客户端\; C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:\ WINDOWS \ SYSTEM32 \ WBEM; C:\ WINDOWS \ SYSTEM32 \ WindowsPowerShell \ V1.0 \; C:\ PROGRAM   Files \ Intel \ Intel(R)管理引擎组件\ DAL; C:\ Program   Files \ Intel \ Intel(R)Management Engine Components \ IPT; C:\ Program Files   (x86)\ Intel \ Intel(R)管理引擎组件\ DAL; C:\ Program Files   (x86)\ Intel \ Intel(R)管理引擎组件\ IPT; C:\ Program Files   (x86)\ Intel \ OpenCL SDK \ 2.0 \ bin \ x86; C:\ Program Files(x86)\ Intel \ OpenCL   SDK \ 2.0 \ bin \ x64; C:\ Program Files(x86)\ Windows   住\共享; C:\ HashiCorp \流浪\ BIN; C:\ PHP; C:\ ProgramData \ ComposerSetup \ BIN; C:\ PROGRAM   文件(x86)\ Git \ cmd; C:\ Program Files(x86)\ Git \ bin; C:\ Program   文件\的NodeJS \; C:\用户\肯尼\应用程序数据\漫游\ NPM]

以下是我的sublime安装包

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

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您可以在本地找到名称为ResourceGeneratorCommand.php的文件:vendor\way\generators\src\Way\Generators\Commands

并评论所有代码if($this->confirm....)

或者您可以复制所有代码以使用代码全部回复:

<?php 
namespace Way\Generators\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

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']
        ];
    }

}

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