3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Request { const METHOD_GET = 'GET'; const METHOD_POST = 'POST'; const METHOD_HEAD = 'HEAD'; const METHOD_PUT = 'PUT'; } $routes = array( '/product-list' => [ Request::METHOD_GET => [ 'alias' => 'catalog_product_list', 'controller' => 'Handel\Catalog\Controller\Product\ProductListController::class', 'method' => 'indexAction', 'requirements' => [], 'options' => [] ] ], '/product/{slug}' => [ Request::METHOD_GET => [ 'alias' => 'catalog_product', 'controller' => 'Handel\Catalog\Controller\Product\ProductController::class', 'method' => 'indexAction' ] ], '/compare' => [ Request::METHOD_GET => [ 'alias' => 'catalog_compare_index', 'controller' => 'Handel\Catalog\Controller\Product\CompareController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_compare_add', 'controller' => 'Handel\Catalog\Controller\Product\CompareController::class', 'method' => 'postAction' ] ], '/category-list' => [ Request::METHOD_GET => [ 'alias' => 'catalog_category_list', 'controller' => 'Handel\Catalog\Controller\Product\CategoryListController::class', 'method' => 'indexAction' ] ], '/category/{slug}' => [ Request::METHOD_GET => [ 'alias' => 'catalog_category', 'controller' => 'Handel\Catalog\Controller\Product\CategoryController::class', 'method' => 'indexAction' ] ], '/manufacturer-list' => [ Request::METHOD_GET => [ 'alias' => 'catalog_manufacturer_list', 'controller' => 'Handel\Catalog\Controller\Product\ManufacturerListController::class', 'method' => 'indexAction' ] ], '/manufacturer/{slug}' => [ Request::METHOD_GET => [ 'alias' => 'catalog_manufacturer', 'controller' => 'Handel\Catalog\Controller\Product\ManufacturerController::class', 'method' => 'indexAction' ] ], '/information-list' => [ Request::METHOD_GET => [ 'alias' => 'catalog_information_list', 'controller' => 'Handel\Catalog\Controller\Information\InformationListController::class', 'method' => 'indexAction' ] ], '/information/{slug}' => [ Request::METHOD_GET => [ 'alias' => 'catalog_information', 'controller' => 'Handel\Catalog\Controller\Information\InformationController::class', 'method' => 'indexAction' ] ], '/terms-and-conditions' => [ Request::METHOD_GET => [ 'alias' => 'catalog_terms', 'controller' => 'Handel\Catalog\Controller\Information\TermsController::class', 'method' => 'indexAction' ] ], '/about-us' => [ Request::METHOD_GET => [ 'alias' => 'catalog_about', 'controller' => 'Handel\Catalog\Controller\Information\AboutController::class', 'method' => 'indexAction' ] ], '/search' => [ Request::METHOD_GET => [ 'alias' => 'catalog_search', 'controller' => 'Handel\Catalog\Controller\Product\SearchController::class', 'method' => 'indexAction' ] ], '/account' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_account', 'controller' => 'Handel\Catalog\Controller\Account\AccountController::class', 'method' => 'indexAction' ] ], '/account/address' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_address_book', 'controller' => 'Handel\Catalog\Controller\Account\AddressBookController::class', 'method' => 'indexAction' ] ], '/account/address/{id}' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_address', 'controller' => 'Handel\Catalog\Controller\Account\AddressController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_account_address', 'controller' => 'Handel\Catalog\Controller\Account\AddressController::class', 'method' => 'postAction' ], ], '/account/forgotten' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_forgotten', 'controller' => 'Handel\Catalog\Controller\Account\ForgottenController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_account_forgotten_post', 'controller' => 'Handel\Catalog\Controller\Account\ForgottenController::class', 'method' => 'postAction' ], ], '/account/login' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_login', 'controller' => 'Handel\Catalog\Controller\Account\LoginController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_account_login_post', 'controller' => 'Handel\Catalog\Controller\Account\LoginController::class', 'method' => 'postAction' ] ], '/account/logout' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_logout', 'controller' => 'Handel\Catalog\Controller\Account\LogoutController::class', 'method' => 'indexAction' ] ], '/account/newsletter' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_newsletter', 'controller' => 'Handel\Catalog\Controller\Account\NewsletterController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_account_newsletter_post', 'controller' => 'Handel\Catalog\Controller\Account\NewsletterController::class', 'method' => 'postAction' ], ], '/account/register' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_register', 'controller' => 'Handel\Catalog\Controller\Account\RegisterController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_account_register_post', 'controller' => 'Handel\Catalog\Controller\Account\RegisterController::class', 'method' => 'postAction' ] ], '/account/order-history/{id}' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_order', 'controller' => 'Handel\Catalog\Controller\Account\OrderController::class', 'method' => 'indexAction' ] ], '/account/order-history' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_order_history', 'controller' => 'Handel\Catalog\Controller\Account\OrderHistoryController::class', 'method' => 'indexAction' ] ], '/account/wishlist' => [ Request::METHOD_GET => [ 'alias' => 'catalog_account_wishlist', 'controller' => 'Handel\Catalog\Controller\Account\WishListController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_account_wishlist_post', 'controller' => 'Handel\Catalog\Controller\Account\WishListController::class', 'method' => 'postAction' ] ], '/affiliate/login' => [ Request::METHOD_GET => [ 'alias' => 'catalog_affiliate_login', 'controller' => 'Handel\Catalog\Controller\Affiliate\LoginController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_affiliate_login_post', 'controller' => 'Handel\Catalog\Controller\Affiliate\LoginController::class', 'method' => 'postAction' ], ], '/affiliate/register' => [ Request::METHOD_GET => [ 'alias' => 'catalog_affiliate_register', 'controller' => 'Handel\Catalog\Controller\Affiliate\RegisterController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_affiliate_register_post', 'controller' => 'Handel\Catalog\Controller\Affiliate\RegisterController::class', 'method' => 'postAction' ] ], '/cart' => [ Request::METHOD_GET => [ 'alias' => 'catalog_cart', 'controller' => 'Handel\Catalog\Controller\Common\CartController::class', 'method' => 'indexAction' ], Request::METHOD_POST => [ 'alias' => 'catalog_cart_post', 'controller' => 'Handel\Catalog\Controller\Common\CartController::class', 'method' => 'postAction' ] ], '/checkout' => [ Request::METHOD_GET => [ 'alias' => 'catalog_checkout', 'controller' => 'Handel\Catalog\Controller\Checkout\CheckoutController::class', 'method' => 'indexAction' ] ], '/checkout/payment-address' => [ Request::METHOD_GET => [ 'alias' => 'catalog_checkout_payment_address', 'controller' => 'Handel\Catalog\Controller\Checkout\BillingAddressController::class', 'method' => 'indexAction' ] ], '/checkout/shipping-address' => [ Request::METHOD_GET => [ 'alias' => 'catalog_checkout_delivery_address', 'controller' => 'Handel\Catalog\Controller\Checkout\ShippingAddressController::class', 'method' => 'indexAction' ] ], '/checkout/shipping-method' => [ Request::METHOD_GET => [ 'alias' => 'catalog_checkout_delivery_method', 'controller' => 'Handel\Catalog\Controller\Checkout\ShippingMethodController::class', 'method' => 'indexAction' ] ], '/' => [ Request::METHOD_GET => [ 'alias' => 'catalog_index', 'controller' => 'Handel\Catalog\Controller\Common\HomeController::class', 'method' => 'indexAction' ] ], ); $output = []; foreach ($routes as $path => $data) { foreach ($data as $http_method => $values) { $alias = $values['alias']; $controller = $values['controller']; $method = $values['method']; $output[$alias] = [ 'path' => $path, 'controller' => [$controller, $method], 'requirements' => [], 'defaults' => [], 'methods' => [$http_method] ]; } } var_dump($output);

preferences:
43.5 ms | 402 KiB | 5 Q