Adding a non-laravel package to my Laravel project with composer Adding a non-laravel package to my Laravel project with composer laravel laravel

Adding a non-laravel package to my Laravel project with composer


This is not a Laravel package, so you don't have Service Provider nor Alias to setup, but this is a PHP package and since you use Composer to install it, it is already autoloaded, so you can just:

Add the package to your composer.json:

{    "require": {        "ghunti/highcharts-php": "~2.0"    }}

Run

composer dumpautoload

And instantiate it:

$chart = new Ghunti\HighchartsPHP\Highchart();

Or use it in the top of your php:

use Ghunti\HighchartsPHP\Highchart;

And you should be able to:

$chart = new Highchart(Highchart::HIGHSTOCK);

Anywhere in your project and it should work.

You can create an alias in app/config/app.php for it if you prefer to use it this way:

'Highchart' => 'Ghunti\HighchartsPHP\Highchart'

But you will still have to instantiate it

$chart = new Highchart();

You won't able to use it as in Laravel

Highchart::doWhatever();

Unless you create a ServiceProvider yourself, of course.