0

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

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

[RuntimeException] 中止

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

[在 0.4 秒内完成,退出代码为 1] [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 (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel \iCLS 客户端\;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) Management Engine Components\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 Live\Shared;C:\HashiCorp\Vagrant\bin;C:\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86 )\Git\cmd;C:\Program Files (x86)\Git\bin;C:\Program Files\nodejs\;C:\Users\Kenny\AppData\Roaming\npm]

以下是我的崇高安装包

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

提前感谢您的帮助。

4

1 回答 1

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

}

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

于 2015-03-20T03:56:33.777 回答