Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Press Laravel Package

moox/press

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation Run these two commands in your Laravel project root:

    composer require moox/press
    php artisan mooxpress:install
    

    This handles:

    • WordPress core installation via roots/wordpress-core-installer.
    • Configuration publishing.
    • Database setup (migrations).
  2. 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:

    • Integrate WordPress posts/pages into Filament resources.
    • Fetch WordPress content dynamically in Laravel views or Filament panels.
    • Example:
      use Moox\Press\Facades\Press;
      
      $posts = Press::posts()->latest()->take(5)->get();
      
  3. Where to Look First

    • Config File: Published at config/press.php (check wp_path, database, and filament_integration settings).
    • Migrations: Located in database/migrations/ (published via vendor:publish).
    • Artisan Commands: Run php artisan to see mooxpress:* commands (e.g., mooxpress:link for symlinking).
    • Documentation: Check the GitHub README for deployment-specific notes (e.g., Nginx/Forge/Valet).

Implementation Patterns

Core Workflows

1. Integrating WordPress Content into Filament

  • Resources: Extend Filament resources to display WordPress data:
    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)),
        ]);
    
  • Widgets: Create Filament widgets to showcase WordPress content:
    use Moox\Press\Filament\Widgets\RecentPosts;
    
    RecentPosts::make()->height('300px');
    

2. Dynamic Content Fetching

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();

3. Customizing WordPress Routes

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.

4. Deployment Patterns

  • Local Development (Valet/Herd): Use the provided wsconfig files to configure WordPress paths and permissions. Example for Herd:
    cp vendor/moox/press/wsconfig/herd/* ~/Library/Application\ Support/Herd/Config/
    
  • Production (Forge/Nginx): Add the Nginx snippet from the README to your site’s config:
    location /wp/ {
        try_files $uri $uri/ /wp/index.php?$query_string;
    }
    
    Run the symlink command post-deploy:
    php artisan mooxpress:link
    

5. Extending WordPress Functionality

  • Custom Taxonomies/Post Types: Register them in WordPress via a custom plugin or functions.php in your theme.
  • Hooks/Filters: Use WordPress hooks in Laravel by leveraging the Press facade’s add_action/add_filter methods:
    Press::add_action('wp_enqueue_scripts', function() {
        wp_enqueue_style('custom-theme', asset('css/custom.css'));
    });
    

Gotchas and Tips

Pitfalls and Debugging

  1. WordPress Not Loading

    • Symlink Issues: Ensure the /wp symlink exists. Run:
      php artisan mooxpress:link
      
      If using Forge, add the deploy.sh script to your deployment hooks.
    • Server Config: Verify your Nginx/Apache config includes the /wp/ location block. Restart the server after changes:
      sudo systemctl restart nginx  # or apache2
      
  2. Database Connection Errors

    • WordPress and Laravel may share a database, but ensure:
      • The wp_options table prefix is unique (e.g., wp_ vs. Laravel’s default).
      • The press.php config specifies the correct database credentials for WordPress.
    • Tip: Use separate databases for Laravel and WordPress to avoid conflicts.
  3. Filament Integration Issues

    • CORS: If accessing WordPress APIs from Filament, ensure CORS headers are configured in WordPress (wp-config.php):
      define('WP_ALLOW_CORS', true);
      
    • Authentication: WordPress REST API routes may require authentication. Use nonces or JWT plugins for secure access.
  4. Plugin/Theme Conflicts

    • WordPress plugins/themes may break Laravel routes. Use a custom wp-config.php to disable scripts:
      define('SCRIPT_DEBUG', false);
      define('CONCATENATE_SCRIPTS', true);
      
  5. Composer Plugin Restrictions

    • If you see roots/wordpress-core-installer errors, ensure your composer.json includes:
      "config": {
          "allow-plugins": {
              "roots/wordpress-core-installer": true
          }
      }
      
    • Run composer clear-cache if issues persist.

Configuration Quirks

  1. WP Path Overrides

    • Changing wp_path in press.php requires updating:
      • Nginx/Apache configs.
      • Filament resource URLs (if hardcoded).
      • Asset paths in WordPress themes/plugins.
  2. Multisite Support

    • Not officially supported. Avoid using WordPress Multisite with this package.
  3. Caching

    • WordPress object cache (e.g., Redis) may conflict with Laravel’s cache. Configure WordPress to use a separate cache backend:
      define('WP_CACHE_KEY_SALT', 'laravel_');
      

Extension Points

  1. 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.

  2. 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.

  3. 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
    }
    
  4. 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();
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver