1. Go to this page and download the library: Download exeplor/ampere library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
/*
* Main configuration
*/
'app' => [
/*
* Ampere url path
*/
'url_prefix' => 'myadminpanel',
],
/*
* Routing configuration
*/
'routing' => [
/*
* Controllers folder
*/
'folder' => 'app/Http/Controllers/Admin',
/*
* Controller namespace
*/
'namespace' => 'App\Http\Controllers\Admin',
/*
* Space route prefix
* Route space name
*/
'prefix' => 'my.custom.name',
// Example: route('my.custom.name.some.method')
/*
* Custom route group
*/
'group' => [
// If you have some specific middleware or other config
// This place for Route::group() arguments
'domain' => env('APP_DOMAIN')
]
],
/*
* Ampere DB configuration
*/
'db' => [
'prefix' => 'amp_'
],
/*
* Authorization config
*/
'auth' => [
/*
* Captcha settings
*/
'google_captcha' => [
'enabled' => env('AMPERE_CAPTCHA_ENABLED', false),
'site_key' => env('AMPERE_CAPTCHA_SITE_KEY'),
'secret_key' => env('AMPERE_CAPTCHA_SECRET_KEY')
]
],
/*
* Installation settings
*/
'install' => [
/*
* Ampere public assets folder
*/
'assets_folder' => 'vendor/admin'
],
/*
* Views configuration
*/
'views' => [
'name' => 'admin'
]
];
/**
* Class HomeController
* @package App\Http\Controllers\Admin
*/
class HomeController extends Controller
{
/**
* @return void
*/
public function foo()
{
// Route result
// GET /admin/home/foo
}
/**
* @route bar
*/
public function firstMethod()
{
// Result
// GET /admin/home/bar
}
/**
* @route entity/{id}
*/
public function secondMethod(int $id)
{
// Result
// GET /admin/home/entity/{$id}
}
/**
* @route update/{id}
* @post
*/
public function thirdMethod(int $id)
{
// Result
// POST /admin/home/update/{$id}
}
/**
* @post secondMethod
*/
public function fourthMethod(int $id)
{
// You can inherit route by method name in this controller
// @post <controller_method_name>
// Result
// POST /admin/home/entity/{$id}
}
/**
* @route some/route
* @put
*/
public function fifthMethod()
{
// Result
// PUT /admin/home/some/route
}
/**
* @route some/route
* @delete
*/
public function sixthMethod()
{
// Result
// DELETE /admin/home/some/route
}
}
$route = HomeController::route('secondMethod', [1]);
echo $route->route(); # return "ampere.home.someroutepath"
echo $route->url(); # return "home/entity/1"
if ($route->access()) {
echo 'This route available for current user';
}
/**
* Class HomeController
* @package App\Http\Controllers\Admin
*/
class HomeController extends Controller
{
/**
* @route foo
* @menu Home
*/
public function home()
{
// Menu items:
// Home > [link to "home/foo"]
}
/**
* @menu Items > First
*/
public function first()
{
// Menu items:
// Home [link to "home/foo"]
// Items
// First [link to "home/first"]
}
/**
* @menu Items > Second
*/
public function first()
{
// Menu items
// Home [link to "home/foo"]
// Items (submenu item)
// First [link to "home/first"]
// Second [link to "home/second"]
}
}
public function home()
{
return $this->render('home', ['value' => 'hello']);
}