1. Go to this page and download the library: Download yangsuda/slimcms 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/ */
yangsuda / slimcms example snippets
use SlimCMS\Core\RouteAction as Route;
Route::get('/path', 'Controller@method'); // GET
Route::post('/path', 'Controller@method'); // POST
Route::put('/path', 'Controller@method'); // PUT
Route::delete('/path','Controller@method'); // DELETE
Route::patch('/path','Controller@method'); // PATCH
Route::gp('/path', 'Controller@method'); // GET + POST
Route::any('/path', 'Controller@method'); // 所有方法
Route::map(['GET','POST'], '/path', 'Controller@method'); // 自定义方法
// 路由分组,支持链式挂载中间件
Route::group('/admin', function () {
Route::gp('/login', 'admin\LoginController@login');
Route::group('', function () {
Route::get('/index', 'admin\MainController@index');
Route::gp('/{path1}/{path2}'); // 动态路由参数
})->add(AdminAuthMiddleware::class)->add(CsrfMiddleware::class);
})->add(SessionMiddleware::class);
namespace app\Controller\main;
use Psr\Http\Message\ResponseInterface;
use Slim\App;
use SlimCMS\Abstracts\ControlAbstract;
class MainController extends ControlAbstract
{
public function __construct(App $app)
{
parent::__construct($app);
}
public function index(): ResponseInterface
{
return $this->view($this->output, 'index');
}
}