Download the PHP package marspress/front-end-route without Composer

On this page you can find all versions of the php package marspress/front-end-route. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package front-end-route

MarsPress FrontEndRoute

Installation

Require the composer package in your composer.json with marspress/front-end-route with minimum dev-main OR run composer require marspress/front-end-route

Usage

You will first need to create a Route Set. You can think of these like a Post Type and the Routes in the set are like the posts of that type.

Route Set

new \MarsPress\FrontEndRoute\Route_Set() takes 5 parameters, 1 required and 4 optional.

Available Methods

Route

new \MarsPress\FrontEndRoute\Route() takes 3 parameters, 2 required and 1 optional.

Creating a Route Set and adding Routes to it

Given the Route Set:

The above would create two routes: /route/set/this-is-a-route and /route/set/this-is-another-route

The add_routes method can take any number of parameters as long as they are a Route instance.

Template Loading

The default template loading is that of WordPress', falling back to the Parent Theme's index.php file.

Default WordPress Theme Scope

Resource: https://developer.wordpress.org/themes/template-files-section/page-template-files/

The PHP files should reside in the root of your Parent or Child theme.

To use WordPress' template scope, the prefix used is marspress-route-, followed by the Route Set's query variable, then the Route's slug.

IMPORTANT: If a Route Set has an archive, the query variable value will be archive, thus you should use marspress-route-test_route-archive.php for the archive template.

Route Set Template Parameter

The Route Set class constructor can take an optional parameter for a template. This will load the given template for all the Routes in the set. This is regardless of the existence of the Theme templates listed above.

This is useful if you are using this dependency inside a plugin and need to load templates from the plugin directory. E.g. your template parameter would look something like this: __DIR__ . '/templates/route_set.php'

If the template file does not exist on the server, it will not be loaded and an admin notice will be displayed to administrators in wp-admin screens.

Route Template Parameter

The Route class constructor can take an optional parameter for a template. This will load the given template for the one Route. This will override all other template loading functionality.

This is useful if you want to load a specific template for a single Route. If you want a more structured and expandable templates loading of Routes and Route Sets, see the section Advanced Template Loading Methodology

If the template file does not exist on the server, it will not be loaded and an admin notice will be displayed to administrators in wp-admin screens.

Advanced Template Loading Methodology

Though you are able to load templates for specific Routes using the WordPress template scope such as marspress-route-test_route-this-is-a-route.php, it is recommended that you use the scope for the Route Set marspress-route-test_route.php and handle the Route template loading from inside that template.

Given the Route Set:

Add a PHP file to the root of your Child Theme, name the file marspress-route-test_route.php

Your PHP file should have this content:

With the above code, you can manage the Route templates within an organized directory. Given the above example, your route templates would go into template-parts/test_route/<route-slug>.php and if the Route's template does not exist in the given directory, it will try to load a default template: template-parts/test_route/default.php.

This method is useful if your Route Sets need to contain different html structures, and when the Routes need to inherit the Route Set structure.


All versions of front-end-route with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marspress/front-end-route contains the following files

Loading the files please wait ....