Starting out with Laravel

I have decided to start out my learning journey with Laravel 5. Laravel has been getting some serious buzz in the PHP community. Being well versed in PHP, I was curious to see how quickly I’ll be able to get something up and running.

So far it’s going alright. I’m feeling somewhat lost at times. Perhaps it is because I’m just jumping in without much prior knowledge (apart from a few Laracasts videos a few months ago). Luckily I have my Laravel expert husband to give me some pointers.

To get started on my database, models and seed data, I have been referencing:

Some issues that I’ve ran into so far

  • The web root for a Laravel project is in the public folder. Pointing to the project directory will give a big fat error.
  • I needed to add this option to my virtual host setup:
  • I couldn’t get my rename column migration to run. It gave this error: [Symfony\Component\Debug\Exception\FatalErrorException] Class ‘Doctrine\DBAL\Driver\PDOMySql\Driver’ not found. A quick search produced this on Stackoverflow. I added it, and the migration now works fine.
  • In one of my models, I referenced another model to set up relationships:
    public function objectives()
       return $this->belongsToMany('Objective', 'users_objectives', 'user_id', 'objective_id')
          ->withPivot('week', 'time_estimate');

    When I ran the seed database command, class ‘Objective’ could not be found. To fix this, add the namespace to the class name, like this:

    return $this->belongsToMany('\TimeTracker\Models\Objective',...)
  • Renaming migration files gives issues, as the migration class name is derived from the migration file name. To rename the migration, rollback, delete the migration and create a new one with the correct name. Or, just rename the class to match the file name (remember: camel case for the class name, snake case for the file name).