Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dane5890's avatar

Too many arguments (Php artisan make:migration create)

Hi I have a laravel 5.4 app and I'm trying to create a table to build a subscriber list. When I try to implement the command php artisan make:migration create_subscribers_table --table=subscribers –-create

I get the error below

[Symfony\Component\Console\Exception\RuntimeException] Too many arguments, expected arguments "command" "name",

I created a database subscriber on my local phpmyadmin. I'm stumped at this point. I'm running this app on Ubuntu 17.

Thanks for the help.

0 likes
13 replies
bipin's avatar

try to create subscriber table with other name

JackJones's avatar

Did you definitely type it in the way you've typed it? I copied and pasted what you wrote and it worked

Does it work without either of the options?

JackJones's avatar

Where does it say that in your reference?

Not that using both would be required, but they're options and not arguments, and it works on 5.5

Jaytee's avatar

@JackJones If you've ever used those arguments before, then you know it's common sense.

--table is for when you want to add columns to an already existing table

--create is for creating a new table

Of course, something is gonna error if you use both.

Straight from the command:

public function handle()
    {
        // It's possible for the developer to specify the tables to modify in this
        // schema operation. The developer may also specify if this table needs
        // to be freshly created so we can create the appropriate migrations.
        $name = trim($this->input->getArgument('name'));

        $table = $this->input->getOption('table');

        $create = $this->input->getOption('create') ?: false;

        // If no table was given as an option but a create option is given then we
        // will use the "create" option as the table name. This allows the devs
        // to pass a table name into this option as a short-cut for creating.
        if (! $table && is_string($create)) {
            $table = $create;

            $create = true;
        }

        // Next, we will attempt to guess the table name if this the migration has
        // "create" in the name. This will allow us to provide a convenient way
        // of creating migrations that create new tables for the application.
        if (! $table) {
            if (preg_match('/^create_(\w+)_table$/', $name, $matches)) {
                $table = $matches[1];

                $create = true;
            }
        }

        // Now we are ready to write the migration out to disk. Once we've written
        // the migration out, we will dump-autoload for the entire framework to
        // make sure that the migrations are registered by the class loaders.
        $this->writeMigration($name, $table, $create);

        $this->composer->dumpAutoloads();
    }```
1 like
JackJones's avatar

Both wouldn't be required, I just wouldn't be as quick to assume it was definitely the issue

Jaytee's avatar

Yeah both aren't required. But only one should be used, otherwise you'll end up with errors like above.

The error occurs because you provide both arguments, but more specifically, due to the order of the arguments.

--create=something --table=something will work fine as create is just overriding

--table=something --create=something will squawk like above (tested for confirmation).

Take note at the code i posted above, since you're passing both, the section here:

if (! $table) {
            if (preg_match('/^create_(\w+)_table$/', $name, $matches)) {
                $table = $matches[1];

                $create = true;
            }
        }

isn't being executed.

JackJones's avatar

I understand, I was pretty clear in my response "Not that using both would be required"

My only point was that his error was complaining about arguments, and that when I tried to replicate his error by copying and pasting what he did, I didn't get the error he did

Jaytee's avatar

Yep, I know. I just posted that as even though they may be arguments/options (whatever you wish to call them), it doesn't mean they're all compatible.

I tested in 5.5, One of them failed (which is the same in this case) and the other one passed with the schema being overwritten to a create method.

Jaytee's avatar

And on that note, if any of you wish to view the class responsible, here is the full namespace and path:

Illuminate\Database\Console\Migrations\MigrateMakeCommand

dane5890's avatar

Thank you all for your responses/. I got it to work. This is my first laravel project

Snapey's avatar

This thread has too many arguments ;-)

1 like

Please or to participate in this conversation.