composer require obrainwave/access-tree# Install with admin interface and Gates integration
php artisan accesstree:install --with-admin --with-gates# Auto-detect and configure User model
php artisan accesstree:configure-user-model --auto-detect
# Or specify manually
php artisan accesstree:configure-user-model --model="App\\Models\\User"// app/Models/User.php
use Obrainwave\AccessTree\Traits\HasRole;
class User extends Authenticatable
{
use HasRole;
// ... rest of your code
}# Create the first admin user
php artisan accesstree:create-admin --email=admin@example.com --password=password# Clear all caches and rebuild autoloader
php artisan accesstree:clear-cache# Test that everything is working
php artisan accesstree:testIf you prefer to install manually:
php artisan vendor:publish --tag="accesstree-migrations"
php artisan migratephp artisan vendor:publish --tag="accesstree-config"php artisan accesstree:seedphp artisan accesstree:install-adminOnce installed, visit /admin/accesstree to access the admin panel.
- URL:
/admin/accesstree/login - Email: Use the email you provided when creating the admin user
- Password: Use the password you provided when creating the admin user
- Visit
/admin/accesstree/login - Login with your admin credentials
- You'll be redirected to the dashboard
- Start managing permissions, roles, and users!
- "No hint path defined for [accesstree]": Run
php artisan accesstree:clear-cache - "This cache store does not support tagging": This is normal for file/database cache drivers. The package will work fine, just without advanced cache tagging.
- Class not found errors: Run
composer dump-autoloadorphp artisan accesstree:clear-cache - Migration errors: Check that your database is properly configured
- Permission errors: Make sure you've added the
HasRoletrait to your User model - View not found errors: Clear view cache with
php artisan view:clear
# Test the package functionality
php artisan accesstree:test
# Debug admin routes and views
php artisan accesstree:debug-routes
# Check if admin interface is working
php artisan route:list | grep accesstreeThe package configuration is in config/accesstree.php. Key settings:
admin_interface.enabled- Enable/disable admin interfacecache_refresh_time- Cache duration in minutescache_driver- Cache driver to use (default: same as Laravel's default)gates.enabled- Enable Laravel Gates integration
For better performance, consider using a cache driver that supports tagging:
// config/cache.php - Set default cache driver
'default' => env('CACHE_DRIVER', 'redis'),
// Or configure AccessTree specifically
// config/accesstree.php
'cache_driver' => 'redis', // or 'memcached'Supported cache drivers:
- ✅ Redis - Best performance, supports tagging
- ✅ Memcached - Good performance, supports tagging
- ✅ File - Basic performance, no tagging (works fine)
- ✅ Database - Basic performance, no tagging (works fine)
- Create your first admin user: Assign roles to users through the admin interface
- Customize permissions: Add your application-specific permissions
- Use in your application: Use the helper functions or service methods
- API integration: Use the RESTful API endpoints for frontend applications
Error: Class "Obrainwave\AccessTree\Models\User" not found
This error occurs when the package cannot find your User model. Here's how to fix it:
# 1. Auto-detect your User model
php artisan accesstree:configure-user-model --auto-detect
# 2. Or specify it manually
php artisan accesstree:configure-user-model --model="App\\Models\\User"
# 3. Or set it in your .env file
echo "ACCESSTREE_USER_MODEL=App\\Models\\User" >> .envCommon User model locations:
App\Models\User(Laravel 8+)App\User(Laravel 7 and below)Illuminate\Foundation\Auth\User(Default Laravel)
If you encounter any issues:
- Check the logs in
storage/logs/laravel.log - Run
php artisan accesstree:testto verify functionality - Check the configuration in
config/accesstree.php - Run
php artisan accesstree:configure-user-model --auto-detectfor User model issues