Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Ahondev/portfolio-v2/llms.txt

Use this file to discover all available pages before exploring further.

The WP SSR framework ships two WP-CLI commands that bridge the gap between code-defined configuration and the live WordPress database. Both commands are registered automatically when the plugin boots and are available through the standard wp CLI binary. They are especially important in staging and production environments, where the framework’s automatic page registration is intentionally disabled and must be triggered manually.

Project WP-CLI Configuration

The repository root ships a wp-cli.yml that points the CLI at the Bedrock directory structure so you never need to pass --path manually:
path: web/wp
server:
  docroot: web
With this in place every wp command resolves WordPress from web/wp/ and serves files with web/ as the document root, matching the web-server configuration.

wp pages:sync

Class: Ahon\WPCMS\App\Console\Commands\SyncPages Signature: pages:sync Description: Sync pages from code definition to WP This command iterates every route registered in configuration/routes/web.php — both plain web routes and CPT (Custom Post Type) archive routes — and calls WebRouter::registerPage() for each one. If a corresponding WordPress page does not yet exist, it is created; pages that already exist are left untouched.

When to Use

In development mode the framework auto-registers pages on each request. In staging and production this automatic registration is disabled for performance and safety, so you must run wp pages:sync manually after:
  • Adding a new route to configuration/routes/web.php
  • Renaming an existing page’s title or slug
  • Setting up a fresh environment from scratch

Example Output

$ wp pages:sync
Registered page Accueil
Registered page Agence
Registered page Devis
Registered page Contact
Registered page Services
Registered page Réalisations
Registered page Blog
Each line confirms a page was found or created in WordPress for the corresponding route definition.

Under the Hood

// app/Console/Commands/SyncPages.php
public function handle()
{
    $router = WebRouter::instance();

    collect($router->routes())
        ->each(function ($route) use ($router) {
            $router->registerPage($route);
            $this->info('Registered page '.$route->name);
        });

    collect($router->cptRoutes())
        ->each(function ($route, $path) use ($router) {
            $wpPostType = get_post_type_object($route->postType::$model);
            $route = new WebRouteDefinition(
                HttpMethod::GET,
                $wpPostType->label,
                $path,
                $route->controller,
                'archive'
            );
            $router->registerPage($route);
            $this->info('Registered page '.$route->name);
        });
}
For CPT routes, the command derives the page title from the registered post type’s label (e.g. get_post_type_object('article')->label"Articles"), then creates a WordPress archive page at the configured path.

wp eloquent:generate

Class: Ahon\WPCMS\App\Console\Commands\GeneratePostTypes Signature: eloquent:generate Description: Generate post types PHP classes This command reads every post type registered with EloquentManager and scaffolds PHP class files in app/PostTypes/. Each generated class extends EloquentCPT and declares a $model property set to the post type slug. A built-in Post class is always generated alongside your custom types.

When to Use

Run wp eloquent:generate after:
  • Registering a new custom post type in configuration/posts.php
  • Renaming a post type slug
  • Performing a fresh project setup

Generated File Example

For a post type registered with the slug article, the command produces:
// app/PostTypes/Article.php
<?php

namespace Ahon\WPCMS\App\PostTypes;

class Article extends \Ahon\WPCMS\Eloquent\EloquentCPT
{
    public static string $model = 'article';
}
The class name is the PascalCase version of the slug. The $model property is used throughout the framework to identify the correct post type when building query builders, routes, and REST responses.
The command deletes all existing files in app/PostTypes/ before regenerating them. Any customisations you add to a generated class — like a category() helper in Article.php — will be lost when you re-run the command. Consider re-running only when adding or renaming post types, not as a routine step.

Example Output

$ wp eloquent:generate
Post Types PHP Classes generated successfully.

Workflow: Adding a New Post Type

1

Define the post type in configuration/posts.php

Open configuration/posts.php and require a new post definition file:
// configuration/posts.php
require_once __DIR__ . '/posts/article.php';
require_once __DIR__ . '/posts/service.php';
require_once __DIR__ . '/posts/realisations.php';
require_once __DIR__ . '/posts/project.php'; // 👈 new
Then create configuration/posts/project.php:
<?php

use Ahon\WPCMS\PostType\PostType;
use Extended\ACF\Fields\Text;
use Extended\ACF\Fields\WYSIWYGEditor;

PostType::create('project', 'Projet', 'Projets', 'portfolio', 'portfolio', true)
    ->fields([
        Text::make('Client', 'client'),
        WYSIWYGEditor::make('Description', 'description'),
    ])
    ->make();
2

Run wp eloquent:generate

With the post type registered, scaffold the corresponding PHP class:
wp eloquent:generate
This creates app/PostTypes/Project.php:
<?php

namespace Ahon\WPCMS\App\PostTypes;

class Project extends \Ahon\WPCMS\Eloquent\EloquentCPT
{
    public static string $model = 'project';
}
3

Use the generated class in controllers and routes

Import the generated class wherever you need to query or route against the post type:
// configuration/routes/web.php
use Ahon\WPCMS\App\PostTypes\Project;
use Ahon\WPCMS\App\Controllers\Web\ProjectController;

Route::CPT('/projets', Project::class, ProjectController::class);
Then sync the new archive page to WordPress:
wp pages:sync
# Registered page Projets
Both commands can be chained in a deployment script. A typical post-deploy sequence for a staging environment looks like:
wp eloquent:generate
wp pages:sync
wp rewrite flush

Build docs developers (and LLMs) love