aimeos/aimeos-laravel · error

abort( 404 );

Error message

abort( 404 );

What it means

The Aimeos PageController::indexAction() renders the CMS content page and aborts the request with a Laravel HTTP 404 when the rendered 'cms/page' client body is empty. This means no CMS page content could be produced for the request — typically because no CMS page exists for the current URL/label in the database, or the cms/page client intentionally output nothing. The library throws it to turn 'missing content' into a proper not-found response instead of rendering an empty page.

Solutions

  1. Create/publish the CMS page for the requested slug in the Aimeos admin (or import CMS content) so the cms/page client renders a body
  2. Verify the requested URL slug matches an existing CMS page record in the database for the current site
  3. Check config shop.page.cms: if you don't use CMS functionality, remove 'cms/page' from the list or ensure the cms frontend controller/provider is available
  4. Clear caches (Aimeos cache, Laravel view/config cache) after adding the content, then retry the URL

Example fix

// before: URL /help returns 404 because no CMS page exists
// after: create the page in admin or seed it, then verify
php artisan aimeos:cache --clear
// ensure a cms item with URL segment 'help' exists for the current site, e.g. via admin UI -> Page -> Add 'help'
Defensive patterns

Strategy: try-catch

Validate before calling

// Check before linking/rendering that the CMS page exists
$page = \Aimeos\Controller\Frontend::create( app('aimeos.context')->get(), 'cms' )->find( $slug );
if( $page === null ) { // slug not available, don't render the link
}

Type guard

function cmsBodyExists( array $aibody, string $key = 'cms/page' ): bool {
    return isset( $aibody[$key] ) && is_string( $aibody[$key] ) && $aibody[$key] !== '';
}

Try / catch

try {
    $response = \Aimeos\Shop\Facades\Shop::get('page.index')->body(); // or your route call
} catch( \Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e ) {
    return response()->view('errors.cms-missing', ['slug' => $slug], 404);
}

Prevention

When it happens

Trigger: The 'cms/page' entry in config shop.page.cms is requested but Shop::get('cms/page')->body() returns an empty string, which happens when the CMS page (tree item / slug) for the current request does not exist in the mshop_cms tables, the page is disabled, or the site/locale context has no matching CMS record.

Common situations: Visiting a CMS URL slug that was never created or was deleted/unpublished; running with a fresh or incomplete database where CMS content was never imported; multi-site setups where the content exists in another site but not the current one; misconfigured 'shop.page.cms' including 'cms/page' when the CMS component isn't set up.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of aimeos/aimeos-laravel@9879c60332 (2026-09-12). Data as JSON: /api/errors/f3569b75ca17ca1b. Report an issue: GitHub.

Appendix: source

Thrown at src/Controller/PageController.php:38

class PageController extends Controller
{
	/**
	 * Returns the html for the content pages.
	 *
	 * @return \Psr\Http\Message\ResponseInterface Response object containing the generated output
	 */
	public function indexAction()
	{
		$params = ['page' => 'page-index'];

		foreach( app( 'config' )->get( 'shop.page.cms', ['cms/page', 'catalog/tree', 'basket/mini'] ) as $name )
		{
			$params['aiheader'][$name] = Shop::get( $name )->header();
			$params['aibody'][$name] = Shop::get( $name )->body();
		}

		if( empty( $params['aibody']['cms/page'] ) ) {
			abort( 404 );
		}

		return Response::view( Shop::template( 'page.index' ), $params )
			->header( 'Cache-Control', 'private, max-age=10' );
	}
}

View on GitHub (pinned to 9879c60332)