Skip to content

Commit

Permalink
feat: refonte app structure
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed May 19, 2020
1 parent 2873f19 commit fb8e989
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace App\Controller;

namespace App\Controllers;

use Bow\Http\Request;
use Bow\Configuration\Loader as Config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Controller;
namespace App\Controllers;

use App\Controller\Controller;
use App\Controllers\Controller;
use Bow\Http\Request;

class WelcomeController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion app/ErrorHandle.php → app/Exceptions/ErrorHandle.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App;
namespace App\Exceptions;

use Bow\Database\Exception\NotFoundException as ModelNotFoundException;
use Bow\Http\Exception\ResponseException as HttpResponseException;
Expand Down
16 changes: 8 additions & 8 deletions app/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ class Kernel extends ApplicationLoader
public function namespaces()
{
return [
'controller' => 'App\\Controller',
'middleware' => 'App\\Middleware',
'configuration' => 'App\\Configuration',
'validation' => 'App\\Validation',
'model' => 'App\\Model',
'controller' => 'App\\Controllers',
'middleware' => 'App\\Middlewares',
'configuration' => 'App\\Configurations',
'validation' => 'App\\Validations',
'model' => 'App\\Models',
];
}

Expand All @@ -30,9 +30,9 @@ public function namespaces()
public function middlewares()
{
return [
'csrf' => \App\Middleware\ClientCsrfMiddleware::class,
'auth' => \App\Middleware\Authenticate::class,
'guest' => \App\Middleware\Guest::class
'csrf' => \App\Middlewares\ClientCsrfMiddleware::class,
'auth' => \App\Middlewares\Authenticate::class,
'guest' => \App\Middlewares\Guest::class
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace App\Middleware;

namespace App\Middlewares;

use Bow\Middleware\AuthMiddleware;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Middleware;
namespace App\Middlewares;

use Bow\Http\Request;
use Bow\Middleware\CsrfMiddleware;
Expand Down
2 changes: 1 addition & 1 deletion app/Middleware/Guest.php → app/Middlewares/Guest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Middleware;
namespace App\Middlewares;

use Bow\Auth\Auth;
use Bow\Http\Request;
Expand Down
2 changes: 1 addition & 1 deletion app/Model/User.php → app/Models/User.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Model;
namespace App\Models;

use Bow\Auth\Authentication as Model;

Expand Down
110 changes: 55 additions & 55 deletions bow
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
#!/usr/bin/env php
<?php

require __DIR__."/vendor/autoload.php";

/**
* Make kernel instance
*/
$kernel = \App\Kernel::configure(__DIR__.'/config');

/**
* Create command instance and set filename
*/
$setting = new \Bow\Console\Setting(__DIR__);
$setting->setNamespaces($kernel->namespaces());

/**
* Change preset destination
*/
$setting->setModelDirectory(__DIR__.'/app/Model');
$setting->setValidationDirectory(__DIR__.'/app/Validation');
$setting->setPackageDirectory(__DIR__.'/app/Configuration');
$setting->setControllerDirectory(__DIR__.'/app/Controller');
$setting->setMiddlewareDirectory(__DIR__.'/app/Middleware');
$setting->setMigrationDirectory(__DIR__.'/migrations');
$setting->setSeederDirectory(__DIR__.'/seeders');
$setting->setComponentDirectory(__DIR__.'/frontend');
$setting->setConfigDirectory(__DIR__.'/config');
$setting->setPublicDirectory(__DIR__.'/public');

/**
* Defines the local server starter
*/
$setting->setServerFilename(__DIR__.'/server.php');
$setting->setVarDirectory(__DIR__.'/var');

/**
* Create console instance
*/
$console = new \Bow\Console\Console($setting);

/**
* Bind kernel to console
*/
$console->bind($kernel);

/**
* Load the custom command application
*/
require __DIR__.'/routes/console.php';

/**
* Start console
*/
$console->run();
#!/usr/bin/env php
<?php

require __DIR__."/vendor/autoload.php";

/**
* Make kernel instance
*/
$kernel = \App\Kernel::configure(__DIR__.'/config');

/**
* Create command instance and set filename
*/
$setting = new \Bow\Console\Setting(__DIR__);
$setting->setNamespaces($kernel->namespaces());

/**
* Change preset destination
*/
$setting->setModelDirectory(__DIR__.'/app/Models');
$setting->setValidationDirectory(__DIR__.'/app/Validations');
$setting->setPackageDirectory(__DIR__.'/app/Configurations');
$setting->setControllerDirectory(__DIR__.'/app/Controllers');
$setting->setMiddlewareDirectory(__DIR__.'/app/Middlewares');
$setting->setMigrationDirectory(__DIR__.'/migrations');
$setting->setSeederDirectory(__DIR__.'/seeders');
$setting->setComponentDirectory(__DIR__.'/frontend');
$setting->setConfigDirectory(__DIR__.'/config');
$setting->setPublicDirectory(__DIR__.'/public');

/**
* Defines the local server starter
*/
$setting->setServerFilename(__DIR__.'/server.php');
$setting->setVarDirectory(__DIR__.'/var');

/**
* Create console instance
*/
$console = new \Bow\Console\Console($setting);

/**
* Bind kernel to console
*/
$console->bind($kernel);

/**
* Load the custom command application
*/
require __DIR__.'/routes/console.php';

/**
* Start console
*/
$console->run();
7 changes: 6 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,10 @@
*
* development | production
*/
'debug' => app_env('APP_ENV', 'development')
'debug' => app_env('APP_ENV', 'development'),

/**
* The app error handler
*/
"error_handle" => \App\Exceptions\ErrorHandle::class
];
21 changes: 17 additions & 4 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* Default authentication branch
*/
"web" => [
"type" => "jwt",
'model' => App\Model\User::class,
"type" => "session",
'model' => App\Models\User::class,
'credentials' => [
'username' => 'email',
'password' => 'password'
Expand All @@ -23,10 +23,23 @@
*/
"admin" => [
'type' => "session",
"model" => App\Model\User::class,
"model" => App\Models\User::class,
'credentials' => [
'username' => 'email',
'password' => 'password'
]
]
],

/**
* Default authentication branch
*/
"api" => [
"type" => "jwt",
'model' => App\Models\User::class,
'credentials' => [
'username' => 'email',
'password' => 'password'
]
],

];
8 changes: 1 addition & 7 deletions routes/app.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<?php

/**
* Just tell Bow which URIs he should answer and give him the
* controller to call when this URL is requested.
* Follow the following example, it gives you an overview on how it works in general.
*/
$app->get('/', 'WelcomeController')->middleware('auth');
$app->get('/login', 'WelcomeController')->middleware('guest');
$app->get('/', 'WelcomeController');

0 comments on commit fb8e989

Please sign in to comment.