WordPress Templates

If you need to use some WordPress standard templates in you theme, you can do it with Alter. Just use the template() method from the Response object. Route::get(‘/search’, function(){ $this->template(‘search’); // Will require (not render) your_theme/search.php });

Views and Layouts

Alter uses all the power of Twig to render templates. You can render a view using the render() method of Callback object. Route::get(‘/’, function(){ $this->render(‘index’); // Will render views/index.html }); You can also organize your views into folders: $this->render(‘cars.index’); // Will render views/cars/index.html And pass data to the views: $this->render(‘cars.index’, [‘car’ => $car]); // Will render views/cars/index.html passing $car Using Twig

Routes

Alter’s Route component is built using the WordPress Rewrite API and FastRoute. Creating routes You can create routes simply calling the static methods of the Route class: Route::get(‘/hello’, function(){ // Here you are! }); You can also specify HTTP methods to routes like GET, POST, PUT, DELETE, PATCH and OPTIONS. Route::post(‘/hello’, function(){ // A POST request to /hello }); Passing

Configuration

Alter’s defaults configuration is located under vendor/alterfw/ampersand/config.php. To override the default configuration just copy the config.php file to your theme’s root directory and made the changes you need.

Installation

Installation via Composer To get started with Alter you will need to create a new theme by running this command in your ‘wp-content/themes’ directory: composer create-project alterfw/alter mytheme Alter requires PHP 5.6+. License The MIT License (MIT). Please see License File for more information.