donjohn/adminlte-generator-bundle
Deprecated/abandoned AdminLTE generator bundle. Project has been canceled; use EasyAdminBundle instead: https://github.com/javiereguiluz/EasyAdminBundle
Verify Compatibility Check if the package works with your Laravel version (likely outdated). Test in a fresh project:
composer create-project laravel/laravel test-adminlte
cd test-adminlte
composer require donjohn/adminlte-generator-bundle
Publish Config Run:
php artisan vendor:publish --tag=adminlte-generator-config
Edit config/adminlte_generator.php to set:
default_namespace (e.g., Admin)theme (AdminLTE assets path)crud_routes (e.g., ['posts' => 'App\Models\Post']).Generate a CRUD
Define a route in routes/web.php:
use DonJohn\AdminLteGeneratorBundle\Routing\GeneratorRouter;
$router = new GeneratorRouter();
$router->add('posts', 'App\Models\Post', ['fields' => ['title', 'content']]);
Run:
php artisan adminlte:generate
Access /admin/posts (note: may require php artisan route:list to confirm).
Use this for internal tools (e.g., content moderation):
ModerationRequest model:
$router->add('moderation', 'App\Models\ModerationRequest', [
'fields' => ['user_id', 'status', 'created_at'],
'title' => 'Moderation Dashboard',
'icon' => 'fas fa-gavel'
]);
resources/views/adminlte_generator/partials/sidebar.blade.php
Scaffold a Model
php artisan make:model Report -m
Add fields to the migration (e.g., title, data, user_id).
Auto-Generate CRUD
Update GeneratorRouter and regenerate:
php artisan adminlte:generate
Access /admin/reports.
Iterate with Templates
Override index.blade.php for custom columns:
{# resources/views/adminlte_generator/reports/index.blade.php #}
<table class="table">
<thead>
<tr>
<th>Title</th>
<th>User</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for report in reports %}
<tr>
<td>{{ report.title }}</td>
<td>{{ report.user->name }}</td>
<td>
<a href="{{ path('admin_reports_edit', {'id': report.id}) }}">Edit</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
Leverage AdminLTE Widgets Add charts or widgets to the dashboard by extending:
resources/views/adminlte_generator/partials/content_header.blade.php
Example:
<div class="box">
<div class="box-header">
<h3 class="box-title">Reports Overview</h3>
</div>
<div class="box-body">
<canvas id="reportChart" height="300"></canvas>
</div>
</div>
Custom Actions Extend the generated controller:
namespace App\Http\Controllers\Admin;
use DonJohn\AdminLteGeneratorBundle\Controller\CrudController;
class ReportCrudController extends CrudController {
public function exportAction() {
// Custom logic (e.g., export to CSV)
return response()->download(...);
}
}
Add a route:
Route::get('/admin/reports/export', [ReportCrudController::class, 'exportAction']);
Form Customization Use AdminLTE’s input groups or custom components:
<div class="form-group">
{{ form_label(form.title, 'Report Title') }}
<div class="input-group">
{{ form_widget(form.title) }}
<span class="input-group-addon"><i class="fa fa-tag"></i></span>
</div>
</div>
Check Generated Routes Run:
php artisan route:list | grep admin
Verify routes like admin_posts_index exist.
Inspect Templates Dump the rendered template to debug:
// In a controller
dd(view()->render('adminlte_generator::posts/index'));
AdminLTE Asset Issues If CSS/JS fails, clear caches:
php artisan cache:clear
php artisan view:clear
Ensure public/adminlte exists (copy from vendor/adminlte).
Deprecated Package Risks
ClassNotFound errors for newer Laravel classes.
Fix: Fork the repo and update dependencies (e.g., symfony/routing).adminlte assets may break if you update AdminLTE.
Fix: Override asset paths in config/adminlte_generator.php:
'theme' => public_path('adminlte'), // Custom path
Template Overrides
{% if %}). Update to {{ }}/@ directives.form_row.blade.php) is missing, copy it from vendor/ to resources/views/adminlte_generator/partials/.Route Conflicts
$router->exclude('App\Models\Post');
Database Schema Assumptions
morphTo or morphMany fields.
Fix: Customize the show template to manually render polymorphic data.Authentication Bypass
Route::middleware(['auth:sanctum'])->group(function () {
$router->add('posts', 'App\Models\Post');
});
Enable Debug Mode
Set APP_DEBUG=true in .env to see template errors.
Check Generator Logs Run with verbose output:
php artisan adminlte:generate --verbose
AdminLTE Console Errors
Open browser dev tools (F12) to catch JS errors (e.g., missing jQuery plugins).
Common Errors & Fixes
| Error | Solution |
|---|---|
Class 'DonJohn\AdminLteGeneratorBundle...' not found |
Update Composer autoloader: composer dump-autoload. |
Call to undefined method |
Fork the package and add missing methods (e.g., getFields()). |
| Blank admin panel | Check resources/views/adminlte_generator/layouts/master.blade.php. |
| CSRF token errors | Ensure @csrf is in forms or use {{ csrf_field() }}. |
Custom Field Types
Extend the generator to support custom fields (e.g., RichText, DateRange):
// In a service provider
$generator->addFieldType('richtext', function ($field) {
return '<div class="form-group">' . $field->widget . '</div>';
});
Dynamic Sidebars
Override sidebar.blade.php to fetch menu items dynamically:
<ul class="sidebar-menu">
{% for item in getMenuItems() %}
<li class="treeview">
<a href="{{ item.link }}">
<i class="{{ item.icon }}"></i> <span>{{ item.title }}</span>
</a>
</li>
{% endfor %}
</ul>
Event Listeners Hook into generation events (if the package supports them) to modify output:
// In AppServiceProvider@boot()
event(new \DonJohn\AdminLteGeneratorBundle\Events\CrudGenerated($crud));
How can I help you explore Laravel packages today?