Installation Run these two commands in your Laravel project root:
composer require moox/press
php artisan mooxpress:install
This handles:
roots/wordpress-core-installer.First Use Case: Embedding WordPress in Filament
After installation, WordPress will be accessible at /wp/ (configurable). Use the moox/press facade or service container to:
use Moox\Press\Facades\Press;
$posts = Press::posts()->latest()->take(5)->get();
Where to Look First
config/press.php (check wp_path, database, and filament_integration settings).database/migrations/ (published via vendor:publish).php artisan to see mooxpress:* commands (e.g., mooxpress:link for symlinking).use Moox\Press\Filament\Resources\PostResource;
PostResource::configureUsing(new PostResource\Pages\ManagePosts())
->columns([
Tables\Columns\TextColumn::make('title')->label('WordPress Title'),
Tables\Columns\TextColumn::make('content')->widget(fn ($record) => Str::limit($record->content, 100)),
]);
use Moox\Press\Filament\Widgets\RecentPosts;
RecentPosts::make()->height('300px');
Use the Press facade to query WordPress data in Laravel:
// Fetch a single post
$post = Press::post()->find(123);
// Query posts with Laravel Eloquent syntax
$featuredPosts = Press::posts()->where('post_status', 'publish')->where('meta_key', 'featured', 'meta_value', '1')->get();
Override the default /wp/ route by publishing the config:
php artisan vendor:publish --tag="press-config"
Update wp_path in config/press.php:
'wp_path' => '/custom-path',
Then update your server config (e.g., Nginx) to proxy requests to /custom-path.
wsconfig files to configure WordPress paths and permissions.
Example for Herd:
cp vendor/moox/press/wsconfig/herd/* ~/Library/Application\ Support/Herd/Config/
location /wp/ {
try_files $uri $uri/ /wp/index.php?$query_string;
}
Run the symlink command post-deploy:
php artisan mooxpress:link
functions.php in your theme.Press facade’s add_action/add_filter methods:
Press::add_action('wp_enqueue_scripts', function() {
wp_enqueue_style('custom-theme', asset('css/custom.css'));
});
WordPress Not Loading
/wp symlink exists. Run:
php artisan mooxpress:link
If using Forge, add the deploy.sh script to your deployment hooks./wp/ location block. Restart the server after changes:
sudo systemctl restart nginx # or apache2
Database Connection Errors
wp_options table prefix is unique (e.g., wp_ vs. Laravel’s default).press.php config specifies the correct database credentials for WordPress.Filament Integration Issues
wp-config.php):
define('WP_ALLOW_CORS', true);
Plugin/Theme Conflicts
wp-config.php to disable scripts:
define('SCRIPT_DEBUG', false);
define('CONCATENATE_SCRIPTS', true);
Composer Plugin Restrictions
roots/wordpress-core-installer errors, ensure your composer.json includes:
"config": {
"allow-plugins": {
"roots/wordpress-core-installer": true
}
}
composer clear-cache if issues persist.WP Path Overrides
wp_path in press.php requires updating:
Multisite Support
Caching
define('WP_CACHE_KEY_SALT', 'laravel_');
Custom Installer Logic
Extend the mooxpress:install command by publishing and modifying the installer template:
php artisan vendor:publish --tag="press-installer"
Override app/Installers/PressInstaller.php.
WordPress API Wrapper
Extend the Press facade to add custom methods. Publish the facade:
php artisan vendor:publish --tag="press-facade"
Override app/Facades/Press.php.
Filament Resource Customization
Create a custom Filament resource for WordPress content by extending PostResource:
namespace App\Filament\Resources;
use Moox\Press\Filament\Resources\PostResource as BasePostResource;
class CustomPostResource extends BasePostResource {
// Override columns, tables, or forms
}
WebSocket Integration
For real-time updates (e.g., live post editing), use Laravel Echo/Pusher with WordPress’s wp_ajax hooks. Example:
Press::add_action('wp_ajax_save_post', function() {
broadcast(new PostUpdated($postId))->toOthers();
});
How can I help you explore Laravel packages today?