-
-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
The TallPress - Laravel Blog Package offers extensive configuration options through both a static configuration file and a dynamic settings system.
The main configuration file is located at config/tallpress.php after publishing.
return [
// Posts per page in listings
'per_page' => 15,
// Your application's User model
'author_model' => 'App\\Models\\User',
// Storage disk for images (public, s3, etc.)
'storage_disk' => 'public',
// Route prefix for public blog
'route_prefix' => 'blog',
// Admin route prefix
'admin_route_prefix' => 'admin/blog',
];'middleware' => [
'web' => ['web'],
'api' => ['api'],
'admin' => ['web', 'auth'],
],Customize middleware stacks for different route groups.
'search' => [
'enabled' => true,
'fields' => ['title', 'excerpt', 'body'],
],Control which fields are searchable and enable/disable search functionality.
'comments' => [
'enabled' => true,
'require_approval' => true,
],-
enabled: Turn comments on/off globally -
require_approval: If true, comments need admin approval before appearing
'images' => [
'max_size' => 2048, // Maximum size in KB
'allowed_mimes' => ['jpg', 'jpeg', 'png', 'gif', 'webp'],
'path' => 'tallpress/images',
'organize_by_date' => true, // Store in year/month folders
],Hierarchical Storage:
When organize_by_date is true, images are stored as:
tallpress/images/
├── 2024/
│ ├── 01/
│ │ └── image.jpg
│ └── 10/
│ └── photo.png
'editor' => [
'type' => 'rich', // 'rich' for WYSIWYG, 'markdown' for textarea
'sanitize_html' => true,
],HTML Sanitization:
Configure allowed HTML tags and attributes:
'html_purifier' => [
'HTML.Allowed' => 'p,br,strong,em,u,s,a[href|title|target],ul,ol,li,blockquote,code,pre,h1,h2,h3,h4,h5,h6,img[src|alt|width|height]',
'HTML.AllowedAttributes' => 'href,title,target,src,alt,width,height',
'HTML.TargetBlank' => true,
'AutoFormat.RemoveEmpty' => true,
],'revisions' => [
'enabled' => true,
'keep_revisions' => 10, // Number of revisions to keep per post
],When a post is updated, old versions are automatically saved. Older revisions are pruned when the limit is reached.
'activity_log' => [
'enabled' => true,
'keep_days' => 90, // Days to keep activity logs
],Tracks all admin actions. Logs older than keep_days are automatically cleaned up.
'roles' => [
'add_role_field' => true, // Add role column to users table
'role_field' => 'role',
'default_role' => 'author',
],Built-in Role System:
If add_role_field is true:
- Migration adds a
rolecolumn touserstable - Three roles:
admin,editor,author - Works out of the box
External ACL Systems:
If you use Spatie Permission, Bouncer, etc., set add_role_field to false:
'roles' => [
'add_role_field' => false,
],Then define the gate in your AppServiceProvider:
use Illuminate\Support\Facades\Gate;
Gate::define('access-tallpress-admin', function ($user) {
return $user->hasRole(['admin', 'editor', 'author']);
});In addition to the config file, the package includes a dynamic settings manager accessible at /admin/blog/settings.
Configure blog settings without editing files:
General Settings:
- Posts per page
- Route prefixes
Search Settings:
- Enable/disable search
- Searchable fields
Comments:
- Enable comments
- Require approval
Images:
- Max upload size
- Allowed formats
- Organization structure
Editor:
- Editor type (Rich Text vs Markdown)
- HTML sanitization
Revisions:
- Enable versioning
- Retention limits
Activity Log:
- Enable logging
- Retention period
use Sajdoko\TallPress\Services\SettingsService;
use Sajdoko\TallPress\Facades\Settings;
// Get a setting (with fallback to config)
$perPage = Settings::get('per_page', 15);
// Set a setting
Settings::set('per_page', 20, 'integer', 'general');
// Set multiple settings
Settings::setMany([
'comments_enabled' => [
'value' => true,
'type' => 'boolean',
'group' => 'comments'
],
'images_max_size' => [
'value' => 3072,
'type' => 'integer',
'group' => 'images'
],
]);
// Get all settings by group
$commentSettings = Settings::getGroup('comments');
// Check if a setting exists
if (Settings::has('per_page')) {
// Setting exists
}
// Delete a setting
Settings::forget('custom_setting');Settings are checked in this order:
-
Database settings (from
tallpress_settingstable) -
Config file (
config/tallpress.php) -
Default value (passed to
get()method)
This allows runtime configuration while maintaining fallbacks.
Initialize settings from config:
php artisan tallpress:init-settingsForce overwrite existing settings:
php artisan tallpress:init-settings --forceThe tallpress:install command automatically initializes settings.
Use .env file for environment-specific values:
BLOG_PER_PAGE=20
BLOG_ROUTE_PREFIX=articles
BLOG_STORAGE_DISK=s3Then reference in config/tallpress.php:
'per_page' => env('BLOG_PER_PAGE', 15),
'route_prefix' => env('BLOG_ROUTE_PREFIX', 'blog'),
'storage_disk' => env('BLOG_STORAGE_DISK', 'public'),- Install S3 driver:
composer require league/flysystem-aws-s3-v3- Configure in
.env:
BLOG_STORAGE_DISK=s3
AWS_ACCESS_KEY_ID=your-key
AWS_SECRET_ACCESS_KEY=your-secret
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=your-bucket- Update config:
'storage_disk' => env('BLOG_STORAGE_DISK', 's3'),Define custom disk in config/filesystems.php:
'disks' => [
'tallpress' => [
'driver' => 'local',
'root' => storage_path('app/tallpress'),
'url' => env('APP_URL').'/storage/tallpress',
'visibility' => 'public',
],
],Then use in tallpress config:
'storage_disk' => 'tallpress',php artisan vendor:publish --tag=tallpress-langAfter publishing, edit resources/lang/vendor/tallpress/{locale}/messages.php:
return [
'posts' => 'Posts',
'create_post' => 'Create Post',
'edit_post' => 'Edit Post',
// Add more translations
];In your config/app.php:
'locale' => 'es', // Spanish
'fallback_locale' => 'en',Disable package routes and define your own:
// config/tallpress.php
'register_routes' => false,Then in your routes/web.php:
use Sajdoko\TallPress\Http\Controllers\PostController;
Route::prefix('articles')->group(function () {
Route::get('/', [PostController::class, 'index']);
Route::get('/{slug}', [PostController::class, 'show']);
});Override policy methods in your AuthServiceProvider:
use Sajdoko\TallPress\Models\Post;
use App\Policies\CustomPostPolicy;
protected $policies = [
Post::class => CustomPostPolicy::class,
];Add custom logic to post events:
use Sajdoko\TallPress\Models\Post;
use App\Observers\CustomPostObserver;
// In AppServiceProvider boot method
Post::observe(CustomPostObserver::class);- Keep sensitive data in .env - Never commit credentials
- Use dynamic settings for runtime changes - Edit via admin UI
-
Cache config in production - Run
php artisan config:cache - Document custom changes - Comment your modifications
- Test after changes - Verify functionality after configuration updates
Next: Learn how to use the tallpress → Usage Guide
Getting Started
User Guides
Development