Skip to content

Commit

Permalink
Fixing PSR-0 autoload issue (#227)
Browse files Browse the repository at this point in the history
* Making the controller PSR-0 Compatible

* Update composer.json

* Dynamic base controller

* Update LogViewerController.php

* Dependency class namespace fix

* Changing the package name back after testing

* Updating documentation
  • Loading branch information
aglipanci authored Apr 22, 2020
1 parent dbfc09d commit a50d2e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $app->register(\Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::cl

Explicitly set the namespace in `app/Http/routes.php`:
```php
$router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'], function() use ($router) {
$router->group(['namespace' => '\Rap2hpoutre\Controllers'], function() use ($router) {
$router->get('logs', 'LogViewerController@index');
});
```
Expand Down
9 changes: 9 additions & 0 deletions src/controllers/BaseController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Rap2hpoutre\Controllers;

if (class_exists("\\Illuminate\\Routing\\Controller")) {
class BaseController extends \Illuminate\Routing\Controller {}
} elseif (class_exists("Laravel\\Lumen\\Routing\\Controller")) {
class BaseController extends \Laravel\Lumen\Routing\Controller {}
}
9 changes: 2 additions & 7 deletions src/controllers/LogViewerController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<?php

namespace Rap2hpoutre\LaravelLogViewer;
namespace Rap2hpoutre\Controllers;

use Illuminate\Support\Facades\Crypt;

if (class_exists("\\Illuminate\\Routing\\Controller")) {
class BaseController extends \Illuminate\Routing\Controller {}
} elseif (class_exists("Laravel\\Lumen\\Routing\\Controller")) {
class BaseController extends \Laravel\Lumen\Routing\Controller {}
}
use Rap2hpoutre\LaravelLogViewer\LaravelLogViewer;

/**
* Class LogViewerController
Expand Down

0 comments on commit a50d2e8

Please sign in to comment.