Skip to content

Instantly share code, notes, and snippets.

@Big-Shark Big-Shark/
Last active Nov 20, 2015

What would you like to do?
Install propel2 for laravel 5.1
  1. Create project
composer create-project laravel/laravel test-laravel-5-and-propel2 --prefer-source --dev --stability=dev
  1. Open dir
cd test-laravel-5-and-propel2
  1. Add propel integration package
composer require propel/propel-laravel:dev-develop
  1. Add providers
  1. Publish config
php artisan vendor:publish --provider 'Propel\PropelLaravel\PropelIntegrationServiceProvider'
  1. Create sample schema
php artisan propel:schema:create --sample
  1. Create simple database
mysql -u root
CREATE DATABASE sample_propel2;
  1. Change config
  1. Remove standard migrations
rm -r database/migrations/*
  1. Create new migrations
php artisan propel:migration:diff
  1. Run migrations
php artisan propel:migration:up 
  1. Build a model
php artisan propel:model:build
  1. Test

  2. Update route file ```php Route::get('/', function () {

    $book = new \App\Models\Book(); $book->setTitle('My Heros'); $book->setIsbn('123154');

    $author = new \App\Models\Author(); $author->setFirstName('Hans'); $author->setLastName('Zimmer');

    $publisher = new \App\Models\Publisher(); $publisher->setName('World');

    $book->setPublisher($publisher); $book->setAuthor($author); $book->save();

    return $book->toArray(); }); ```

  3. Start php server Shell php artisan serve

  4. Open url http://localhost:8000/

  5. Enjoy results.

Install debugbar

  1. Install package
composer require barryvdh/laravel-debugbar 
  1. Add provider
  1. Publish config
php artisan vendor:publish --provider ' Barryvdh\Debugbar\ServiceProvider'
  1. Add boot method for AppServiceProvider
$connectionWrapper = \Propel\Runtime\Propel::getServiceContainer()->getConnection();
//$connectionWrapper->setLogMethods(['__construct', 'beginTransaction', 'commit', 'rollBack', 'forceRollBack', 'prepare', 'exec', 'query', '__destruct']);
$traceablePdo = new \DebugBar\DataCollector\PDO\TraceablePDO($connectionWrapper->getWrappedConnection());
$this->app['debugbar']->addCollector(new \DebugBar\DataCollector\PDO\PDOCollector($traceablePdo));

This comment has been minimized.

Copy link

commented Oct 30, 2015

Installation of propel 2 worked when i set following in composer.json

"minimum-stability": "alpha",
"prefer-stable" : true

This comment has been minimized.

Copy link

commented Oct 30, 2015

Question regarding debugbar installation. When i add boot method in AppServiceProvider i get following error:

No connection defined for database "default". Did you forget to define a connection or is it wrong written?

This comment has been minimized.

Copy link

commented Nov 20, 2015

In my case, the boot method of AppServiceProvider (AppServiceProvider::boot) calls before init of propel services, that leads to this error: "No connection defined for database "default"... bla bla bla"

I created a new service provider, registered in config/app.php, and I put code from "Add boot method for AppServiceProvider" into this new provider's boot method. After this, problem disappeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.