Skip to content

Commit

Permalink
Merge pull request #28 from phpooya/master
Browse files Browse the repository at this point in the history
bug-fix for lumen frame work:
  • Loading branch information
ovac authored Oct 8, 2021
2 parents 6c75161 + f6bd0ae commit c10bd89
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
composer.lock
.php_cs.cache
/vendor/
/.idea
/public
.couscous/
.phpintel/
.phpintel/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ This will create an `idoc.php` file in your `config` folder.
### Lumen
- Register the service provider in your `bootstrap/app.php`:
```php
$app->register(\OVAC\IDoc\IDocServiceProvider::class);
$app->bind('path.public', function ($app) { return $app->basePath('../your-public-path'); });
$app->register(\OVAC\IDoc\IDocLumenServiceProvider::class);
```
- Copy the config file from `vendor/ovac/idoc/config/idoc.php` to your project as `config/idoc.php`. Then add to your `bootstrap/app.php`:
```php
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"league/fractal": "^0.17.0"
},
"autoload": {
"files": [
"helpers/helpers.php"
],
"psr-4": {
"OVAC\\IDoc\\": "src/idoc"
}
Expand Down
13 changes: 13 additions & 0 deletions helpers/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
if (! function_exists('public_path')) {
/**
* Get the path to the public folder.
*
* @param string $path
* @return string
*/
function public_path($path = '')
{
return app()->make('path.public').($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path);
}
}
9 changes: 9 additions & 0 deletions resources/routes/lumen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

/** @var Laravel\Lumen\Routing\Router $router */

//This is the route for the documentation info page.
$router->get('info', [function () { return view('idoc::partials.info'); }, 'as' => 'info']);

//This is the route for the root documentation view page.
$router->get('', [function () { return view('idoc::documentation'); }, 'as' => 'root']);
38 changes: 38 additions & 0 deletions src/idoc/IDocLumenServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace OVAC\IDoc;

class IDocLumenServiceProvider extends IDocServiceProvider
{
public function boot()
{
$this->registerRoutes();
$this->registerPublishing();

$this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'idoc');
$this->loadViewsFrom(__DIR__ . '/../../resources/views/', 'idoc');

if ($this->app->runningInConsole()) {
$this->commands([
IDocGeneratorCommand::class,
]);
}
}

protected function registerRoutes()
{
app()->router->group($this->routeConfiguration(), function ($router) {
require __DIR__ . '/../../resources/routes/lumen.php';
});
}

protected function routeConfiguration()
{
return [
'domain' => config('idoc.domain'),
'prefix' => config('idoc.path'),
'middleware' => config('idoc.middleware', []),
'as' => 'idoc',
];
}
}
6 changes: 3 additions & 3 deletions src/idoc/IDocServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function boot()
*
* @return array
*/
private function registerRoutes()
protected function registerRoutes()
{
Route::group($this->routeConfiguration(), function () {
$this->loadRoutesFrom(__DIR__ . '/../../resources/routes/idoc.php', 'idoc');
Expand All @@ -46,7 +46,7 @@ private function registerRoutes()
*
* @return void
*/
private function registerPublishing()
protected function registerPublishing()
{
if ($this->app->runningInConsole()) {
$this->publishes([
Expand All @@ -68,7 +68,7 @@ private function registerPublishing()
*
* @return array
*/
private function routeConfiguration()
protected function routeConfiguration()
{
return [
'domain' => config('idoc.domain', null),
Expand Down

0 comments on commit c10bd89

Please sign in to comment.