Upon attempting to run the default migrations, an Exception is thrown due to an invalid class name.
vagrant@homestead:~/code/payments$ php artisan migrate
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class '' not found
I understand this is generally due to a mismatch between the migration filename, and the name of the class, but I can produce this even when the only migration present is the default Laravel CreateUsersTable.
I've stepped through the code, and I'm struggling to see how Migrator::resolve($file) actually works? Specifically Line 415:
$class = Str::studly(implode('_', array_slice(explode('_', $file), 4)));
Locally this appears to take a string - 0001_create_users_table - and return an empty string. I know it has to work; it's been there for so long, and has been ran thousands upon thousands of times! Yet I can't see how.
In case I was missing something obvious - a combination of a messy sleep pattern and recovering from the flu is my excuse ;) - I wrote a demo on 3v4l to demonstrate (a) how it empties the string, and (b) how I can't see it ever working correctly. The demo is here
I got the migrations running with the following, as an interim:
// Use '@' to silence pass-by-reference error with end()
$class = @Str::studly(end(explode('_', $file, 2)));
I renamed all my migrations earlier, including the default ones, so they had the different filename structure: 0001_My_Migration_Name. When renaming them I didn't pay enough attention to the numerical suffix of all the migrations: YYYY_MM_DD_XXXXXX.. and here we are, entirely my own mistake.
Fortunately I mentioned it in a Slack channel, and someone (I think @devonzara?) was able to point me in the right direction - complete with better 3v4l demo.
Well, I think the same @FergusInLondon
If run "php artisan migration [filename]" its not elegant (and usefull neither) put datetime in start of file. If I wanna refactory my db project, I need create many "update files" and not sounds good to me.
Well, I think that order of migration files can be set in other file class. Like a MigrationsOrder. So... good point @FergusInLondon .
Most helpful comment
User Error.
I renamed all my migrations earlier, including the default ones, so they had the different filename structure:
0001_My_Migration_Name. When renaming them I didn't pay enough attention to the numerical suffix of all the migrations:YYYY_MM_DD_XXXXXX.. and here we are, entirely my own mistake.Fortunately I mentioned it in a Slack channel, and someone (I think @devonzara?) was able to point me in the right direction - complete with better 3v4l demo.