Git Product home page Git Product logo

composeur-laravel's Introduction

A note about Laravel 4

Laravel 4 leverages Composer, so this bundle is obsolete.

A Composer bundle for Laravel

Not sure what's going on here? Here are the Laravel docs, and here are the Composer docs.

I can't take much credit at all for what's going on here. Praise and adoration go to the Laravel and Composer people.

Quick Start

  1. Install the bundle

     php artisan bundle:install composeur
    
  2. Add composeur to bundles.php

     return array(
         'composeur' => array(
         	'auto' => true,
         ),
     );
    
  3. Create application/config/composeur.php

     return array(
     	'auto_update' => true, /* <== You'll need that */
     	'require' => array(
     		/* Composer require key styled as an associative array */
     		/* http://getcomposer.org/doc/01-basic-usage.md#the-require-key */
     	),
     );
    
  4. Get out there and use your Composer packages

Gotcha: auto_update requires write permissions in the {base} and {base}/vendor directories
Note: The first page load after configuration changes will take a while

A Partial Example

With this application/config/composeur.php

return array(
    'auto_update' => true,
    'require' => array(
        'monolog/monolog' => '1.0.*',
    ),
);

Monolog will be available anywhere in your Laravel application, so you could say

Route::get('/', function()
{
    $log = new Monolog\Logger('test');
    $log->pushHandler(new Monolog\Handler\StreamHandler(path('storage') . 'logs/mono.log', Monolog\Logger::WARNING));
    $log->addWarning('Hey, look! A visitor!');

    return View::make('home.index');
});

Get Started in a Slightly More Advanced Way

  1. Install the bundle

     php artisan bundle:install composeur
    
  2. Add composeur to bundles.php

     return array(
         'composeur' => array(
         	'auto' => true,
         ),
     );
    
  3. Set up composeur (installs Composer in the {base} dir)

     php artisan composeur::setup
    
  4. Create application/config/composeur.php (or don't, see below)

     return array(
     	'auto_update' => false, /* <== This can be omitted */
     	'require' => array(
     		/* Composer require key styled as an associative array */
     		/* http://getcomposer.org/doc/01-basic-usage.md#the-require-key */
     	),
     );
    
  5. Now use the composeur bundle's Cli task

     php artisan composeur::cli:install
    

    or

     php artisan composeur::cli:update
    

    etc...

Note: With auto_update set to false, you are responsible for installing and updating your Composer packages.

More thoughts

Running php artisan composeur::cli:update versus php composer.phar update

It's not necessary to use the composeur bundle's Cli task to run Composer. Running php artisan composeur::setup installs composer.phar in the {base} directory, so from there you can simply run php composer.phar [command].

Not adding application/config/composeur.php

If you choose, you need not create application/config/composeur.php. As mentioned above, after the composeur bundle is setup, you can use it from the {base} directory, so just create your own composer.json file there and get going. Warning: if you create your own composer.json and later create application/config/composeur.php, your composer.json might get eaten.

Autoloaders and namespace conflicts

This bundle adds Composer's autoloader to PHP's collection of autoloaders. It's added after Laravel's, so Laravel should have the first shot at resolving classes and namespaces. I suppose this means there is some chance of namespaces being resolved by Laravel when you want them to be resolved by Composer, but I guess you can figure that out.

License

MIT license - http://www.opensource.org/licenses/mit-license.php

composeur-laravel's People

Contributors

joecwallace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.