Giter Site home page Giter Site logo

Comments (40)

taylorotwell avatar taylorotwell commented on May 5, 2024

How did you create the migration? Using Artisan? Artisan should dump the autoloads for you when a migration is created.

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

Also is this on a package or on your app?

from framework.

driesvints avatar driesvints commented on May 5, 2024

It's on the app. I'm using a clean Laravel 4 installation.

I created the migration with Artisan, yes. I did use the --env=local flag because otherwise it would try to use the default database config file instead of my development database config file.

from framework.

driesvints avatar driesvints commented on May 5, 2024

Could it perhaps be a permission problem? Should some folders/files be write able in the /vendor folder?

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

Where did it place the migration? In app/database/migrations?

from framework.

driesvints avatar driesvints commented on May 5, 2024

Yep, exactly.

from framework.

driesvints avatar driesvints commented on May 5, 2024

I just installed Laravel 4 at home on my home dev machine and here I don't get the error I had at work. I'll try to reinstall again tomorrow at work to see if I can get it to work there as well.

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

OK. I've never seen this error.

from framework.

driesvints avatar driesvints commented on May 5, 2024

I tried it again by changing some things on the original repository like tweaking permissions and manually removing the Autoload class in vender/composer/autoload_classmap.php and reinstalling the migration but no luck. Here is the problem at hand:

I did: php artisan migrate --env=local

PHP Fatal error:  Class 'CreateUsersTable' not found in /foo/bar/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 290
<!DOCTYPE html>
<html>

and so on...

I'm trying to install a fresh Laravel installation but it seems that Github is having some issues at the moment (when i run composer.phar install):

Screen Shot 2013-01-16 at 09 48 49

No luck either trying to clone it manually:

Screen Shot 2013-01-16 at 09 49 00

I'll try again later.

from framework.

driesvints avatar driesvints commented on May 5, 2024

It was a Github issue apparently: https://status.github.com/messages. I can clone the repo now.

I set up a new Laravel 4 installation, followed the steps I've taken previously and again ran into the same problem.

Here are the exact steps I've taken:

  • Followed the Laravel installation guide on http://four.laravel.com/docs/installation
  • Set up a virtual host pointed towards the public folder.
  • Created a local dev environment in start.php with following code:
$env = $app->detectEnvironment(array(

    'local' => array('*.loc'),

));
  • Set up a dev database in app/config/local/database.php with following code:
return array(

    'connections' => array(

        'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'laraveltest',
            'username'  => 'root',
            'password'  => 'root',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),

    ),
);
  • Ran php artisan migrate:install --env=local
  • Ran php artisan migrate:make create_users_table
  • Set up the database code in the created migration file like this:
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function($table)
        {
            $table->increments('id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }

}
  • Ran php artisan migrate --env=local and bumping in the error:
PHP Fatal error:  Class 'CreateUsersTable' not found in /foo/bar/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 290
<!DOCTYPE html>
<html>

and so on...

That sums up everything. Pretty much stuck now :-/

from framework.

driesvints avatar driesvints commented on May 5, 2024

It's definitely related to my machine because I can get it to work no problems at home, I just have no clue why it doesn't writes the class in the composer Autoload file when it installs the migration.

I've setted permissions to 777 on all files but that doesn't seems to be the problem.

from framework.

jackmcdade avatar jackmcdade commented on May 5, 2024

Having the same problem.

from framework.

driesvints avatar driesvints commented on May 5, 2024

I've made a temp workaround by manually adding the classname to the composer autoload file. Add the classname in your migration file to this file: vendor/composer/autoload_classmap.php.

'<class name>' => $baseDir . '/app/database/migrations/<migration filename>.php',

Then run php artisan migrate again (perhaps with the --env= param).

from framework.

thinksaydo avatar thinksaydo commented on May 5, 2024

Same problem here as well. Fresh install. On a Mac running PHP 5.4.x.

from framework.

thinksaydo avatar thinksaydo commented on May 5, 2024

Running composer dump-autoload fixes the issue... I noticed /vendor/composer/autoload_classmap.php was out of date. So, apparently this command is still needed for some setups. Might be a permissions issue.

from framework.

bpierre avatar bpierre commented on May 5, 2024

Same problem, fixed with composer dump-autoload. Maybe the migrations documentation could be updated to specify that migrate:make does not only create a file, it also updates vendor/composer/autoload_classmap.php.

@taylorotwell:

Artisan should dump the autoloads for you when a migration is created.

OK, but the vendor directory is ignored by git, how to share the updates? Should I add vendor to the project repository, or do you recommend to run composer dump-autoload each time a new migration class has been added by someone else?

I am not familiar with Composer, but it seems awkward to manually handle the class loading system, and to rely on a modified vendor directory :-/

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

How do you guys have Composer installed on your systems? Using a local composer.phar in the project directory or do you have the composer file in your bin?

In other words, what exact command do you type on the terminal to run Composer?

from framework.

jackmcdade avatar jackmcdade commented on May 5, 2024

I've tried it both ways, using a composer.phar file in my bin, and in the local project.

% php artisan migrate

from framework.

thinksaydo avatar thinksaydo commented on May 5, 2024

I have composer.phar in my bin and access it via an alias as "composer" - I'm running latest version of Composer.

from framework.

driesvints avatar driesvints commented on May 5, 2024

I have composer.phar installed in /usr/local/bin (working on OS X 10.8).

I run composer with: $ composer.phar install
I run migrations with: $ php artisan migrate --env=local

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

I've still never come across this particular error, but will put a note in the documentation to try a composer update if your migration can't be found.

from framework.

gerob avatar gerob commented on May 5, 2024

I have the same issue with migrations and local environments. I am on Windows 7 with Composer installed globally. I was trying to use the migrations from a workbench where I am building a simple blog. I had to manually add the paths to the workbench to get the migrations to run.

Adding this here for anyone else that has this issue. This is the path Artisan created the migrations at for me with the workbench. I am using Sentry for Users and Admin functions and the migrations for that ran fine with the mapping being added to autoload_classmap.php.

'CreatePostsTable' => $baseDir . '/workbench/bit-chisel/blog/src/migrations/2013_01_25_023930_create_posts_table.php',
'CreateCommentsTable' => $baseDir . '/workbench/bit-chisel/blog/src/migrations/2013_01_25_032838_create_comments_table.php',

from framework.

robertovg avatar robertovg commented on May 5, 2024

Same error on ubuntu 12.10, @driesvints thanks for the workarround! I haven't this error with windows 8.

from framework.

howlowck avatar howlowck commented on May 5, 2024

Have the same error on Mac with php5.4.x.

from framework.

comanche avatar comanche commented on May 5, 2024

I had the same problem on Ubuntu 12.10. I previously had composer.phar in the parent directory of my Laravel 4 project folder. I watched Composer's autoload_classmap.php as I created a migration. The map was not updated eventhough the migration php code was generated. No error messages. I Moved local composer.phar into the base directory of Laravel 4 project. Created another migration. Same message in the shell. However the map is updated. Migration and rollback worked properly.

from framework.

fbastage avatar fbastage commented on May 5, 2024

I'm having the same issue on a fresh install. Just installed composer.phar and laravel 4 yesterday as per http://four.laravel.com/ , set up secret key.

Following tutorial by Andrew Perkins at http://www.youtube.com/watch?v=lEZ8cnVGVZE&list=PL09BB956FCFB5C5FD&index=1 (tutorial is based on Laravel 3, I'm making appropriate adjustments).

Created 2nd migration in this tutorial (add_authors).

  1. The migration applies properly and populates db with a few rows in a recently created 'authors' table. !!! So at this point the autoloader and command line 'php artisan migrate' work properly. !!!

  2. When I try 'php artisan migrate:rollback', I get an error that the class does not exist. The error is in the resolve() function. >> see vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 303

return new $class;


Not knowing enough about Laravel at this point, I don't know how to resolve this, even as a short-term workaround, other than perhaps require_once() in the the resolve() routine that tries to instantiate the class, if !class_exists().

Any suggestions would be appreciated.

from framework.

fbastage avatar fbastage commented on May 5, 2024

on the advice of a coworker, I ran 'composer.phar update' which resolved my issue. I guess this issue has been fixed in the framework and updating it worked well.

from framework.

jrahmy avatar jrahmy commented on May 5, 2024

@fbastage In my experience, if you don't run artisan dump-autoload, you will be able to migrate the database but not roll-back. Dumping the autoload file (also done on composer update) fixes rolling back.

from framework.

warrenca avatar warrenca commented on May 5, 2024

PHP: v5.4.4
OSX: 10.7.5

I was using Way/Generators and successfully run the migration, but when running php artisan migrate:rollback, I got the following error.

$ php artisan migrate:rollback
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'CreateFeedsTable' not found","file":"\/Volumes\/Data HD\/User\/Sites\/project\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Migrations\/Migrator.php","line":301}}

so what I did is to run the composer.phar update like most of the people here and it solves my problem

$ composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Updating symfony/console dev-master (v2.3.0- => 2c29086)
    Checking out 2c29086a53686d9dcb11353b9c15f946808ebe04

Writing lock file
Generating autoload files
Generating optimized class loader...
Compiling common classes...

$ php artisan migrate:rollback 
Rolled back: 2013_05_06_091607_create_feeds_table

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

composer dump-autoload

from framework.

rrosiek avatar rrosiek commented on May 5, 2024

I also was able to migrate a fresh database properly, but could not rollback or refresh. I'm using psr-0 style namespacing and folder organization. I had completely cutout my classmap attributes in composer.json and moved everything except the database folder. Putting it back for only the database items and running composer dump-autoload worked. So what I ended up with (which still may not be best practice):

"autoload": {
    "psr-0": {
        "MyApp": "app/src"
    },
    "classmap": [
        "app/database/migrations",
        "app/database/seeds"
    ]
},

Seems really obvious after looking at it now...I suppose I could have namespaced my database migrations, but seems pretty unnecessary.

from framework.

taylorotwell avatar taylorotwell commented on May 5, 2024

Yeah dump-autoload is required before rolling back I believe.

On May 12, 2013, at 8:56 PM, phishman9 [email protected] wrote:

I also was able to migrate a fresh database properly, but could not rollback or refresh. I'm using psr-0 style namespacing and folder organization. I had completely cutout my classmap attributes in composer.json and moved everything except the database folder. Putting it back for only the database items and running composer dump-autoload worked. So what I ended up with (which still may not be best practice):

"autoload": {
"psr-0": {
"MyApp": "app/src"
},
"classmap": [
"app/database/migrations",
"app/database/seeds"
]
},
Seems really obvious after looking at it now...I suppose I could have namespaced my database migrations, but seems pretty unnecessary.


Reply to this email directly or view it on GitHub.

from framework.

 avatar commented on May 5, 2024

composer dump-autoload fixed my problem!

from framework.

 avatar commented on May 5, 2024

Hi ,
I think this problem is caused by the composer classmap.
It seems when i run migrate:create command, it should update the composer classmap, but the user i use doesn't have the privilege to update the composer classmap,but it desn't display the error.
So this problem can be fixed by sudo composer dump-autoload or by sudo migrate:create .
I think we need to update migrate:create command. When the command didn't updated the classmap ,it should display error,not show successful infomation as usual.

from framework.

siaobukol avatar siaobukol commented on May 5, 2024

i have the same problem
in my case i just updated my composer "composer update" and it works perfectly

from framework.

fharbe avatar fharbe commented on May 5, 2024

I am having a similar issue right now ...

I deleted one migration class and now I can't run artisan migrate:refresh or artisan migrate:reset anymore..

Any ideas?

Comment here: #2105

from framework.

desertcrystal avatar desertcrystal commented on May 5, 2024

Same issue with same solution:
composer dump-autoload

from framework.

timzwier avatar timzwier commented on May 5, 2024

Im getting the same error, but composer dump-autoload does not solve the issue. Running all commands with and without sudo, I can't seem to get the migration to work.

from framework.

lionelgaillard avatar lionelgaillard commented on May 5, 2024

Hi,

Concerning workbench's dumpings, one problem is than it fail silently.
Try to cd inside your package inside the workbench, then run composer dump-autoload from there.

It happens several times that my package's composer.json was not valid because I left one extra comma and the error was never reported otherwise.

Hope it could help.

from framework.

gnufred avatar gnufred commented on May 5, 2024

Just had this problem myself with Laravel 4.1 on Ubuntu 14.04 LTS.
Here is how I fixed it

cd /home/user/projects/laravel_site/
curl -sS https://getcomposer.org/installer | php
php composer.phar dump-autoload

php artisan dump-autoload did not work for me.

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.