aecodes / admin-panel
A simplistic framework agnostic admin panel
Installs: 28
Dependents: 1
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/aecodes/admin-panel
Requires
- php: ^7.2
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2025-10-22 03:23:28 UTC
README
framework agnostic admin panel.
Goal
trying to make it as minimal as possible. it allows you to create multiple pages with different types (table, form). without intervening much with your code base.
ps: you still need to setup your routes, the authentication etc...
Response
We allow multiple type of responses, as a default we used php views, but we figured for laravel users as an example, would use blade instead, so one possible solution is to create a different Renderer.
For now we have two default Renderers:
DefaultRendererthis just returns an array as outputJsonRendererthis returns json output
To create a Renderer make it extends Aecodes\AdminPanel\Responses\Renderer. then add it to config.
Currently supported Layouts
- Table (Takes array of TD, every TD can be custom rendered)
- Form (Takes array of Fields)
- Div (the only use case is to have customized wrappers)
- It's possible to create your own widgets.
ps: widgets implements Widget interface.
Currently supported Form fields
- Input (text, password, email, number, ...)
- Radio
- Select
- Textarea
- Checkbox
- Image (upload single image)
How to setup
- install with composer
- create a config file using
config/panel.phpas a starting point. - create (singleton) instance of
Dashboardclass, make sure to pass the config as an array.
$config = require './config/panel.php'; Aecodes\AdminPanel\Dashboard::setup($config);
How to create an admin page
- create a new class extending the
Panelclass - for convenience set the properties for both
$name&$descriptionof the panel (visible on the page). - create a
querymethod that returns the array of data.
function query(): array { // get data from database. return Page::all()->toArray(); }
- create a
rendermethod that returns an array of widgets.
- to create a table
function render(): array { return [ Table::make([ // (label, name) both are optional TD::make('#', 'id'), // it's also possible to use Table::column Table::column('Title', 'title'), ]) // ... ]; }
- to create a form
function render(): array { return [ Form::make([ Input::make('title')->title('Title'), // form submit Action::button('Save'), ]) ->action('#') ->method('post'), // ... ]; }
- to finish up, in the callback of your route, just return a new instance of the class you created.
// callback for some route public function index() { // PagesTable extends Panel return (new Response(new PagesTable))->render(); }
Extendability
Layouts
when extending the Panel class you can specify the $layout property.
Views
this doesn't ship with a view layer. you can use the default (soon) views packages.
Config
The default config is:
return [ // current renderer. 'renderer' => 'default', // add new renderer here. 'renderers' => [ 'json' => Aecodes\AdminPanel\Responses\JsonRenderer::class, 'default' => Aecodes\AdminPanel\Responses\DefaultRenderer::class, ], // default classes for button and a tag. 'classes' => [ 'link' => '', 'button' => '', ], // global menus, can be and array or callback 'menu' => function () { return []; }, // input old value. 'old_value' => function ($name, $default) { return $default; }, // global errors (i.e: validation errors) 'errors' => function () { return []; } ];