Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #68 from bleeloe/master
Browse files Browse the repository at this point in the history
Laravel 5.4 compatibility
  • Loading branch information
cossou authored Jun 8, 2017
2 parents 3d9a098 + d647a91 commit c238012
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,43 @@ and thats it.

### Using Laravel 5?

We don't provide a specific package for L5 but you can easily use JasperPHP.
Add `JasperPHP\JasperPHPServiceProvider::class` to config `config/app.php` in service provider

File `config/app.php`

```php
<?php
.......
.......
'providers' => [
.......
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
//insert jasper service provider here
JasperPHP\JasperPHPServiceProvider::class
],
......
......

```

Uses in Controller by add `use JasperPHP` after namespace
```php
<?php
namespace App\Http\Controllers;
use JasperPHP; // put here
......
......
public function generateReport()
{
//jasper ready to call
JasperPHP::compile(base_path() . '/vendor/cossou/jasperphp/examples/hello_world.jrxml')->execute();
}
......
```

Uses in Route
```php
use JasperPHP\JasperPHP as JasperPHP;

Expand Down
18 changes: 7 additions & 11 deletions src/JasperPHP/JasperPHPServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,28 @@

use Illuminate\Support\ServiceProvider;

class JasperPHPServiceProvider extends ServiceProvider {

class JasperPHPServiceProvider extends ServiceProvider
{
const SESSION_HASH = '_JasperPHP';

/**
* Register the service provider.
*
* @return void
*/
public function register() {

$this->app['jasperphp'] = $this->app->share(function()
{
public function register()
{
$this->app->singleton('jasperphp', function ($app) {
return new JasperPHP;
});


/**
* Register the alias.
*/
$this->app->booting(function()
{
$this->app->booting(function () {
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('JasperPHP', 'JasperPHP\Facades\JasperPHP');
});

}

}
}

0 comments on commit c238012

Please sign in to comment.