Download the PHP package webstractions/sage-xpress without Composer
On this page you can find all versions of the php package webstractions/sage-xpress. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webstractions/sage-xpress
More information about webstractions/sage-xpress
Files in webstractions/sage-xpress
Package sage-xpress
Short Description Extends Sage ~9-beta with Blade directives, component providers, streamlined configurations, and more.
License MIT
Homepage https://github.com/webstractions/sage-xpress
Informations about the package sage-xpress
Sage Xpress
A collection of extensions, providers, and Blade revisions for your Roots\Sage 9.x beta themes.
- Blade Directives: @directives for loop, query, sidebar, FontAwesome, and more.
- Menu Provider: Register nav menu and markup via configuration file.
- Sidebar Provider: Register sidebar and widget markup via configuration file.
- Comment Form Provider: Register comment form markup via configuration file.
- Schema Provider Quickly add schema.org markup via @schema directive.
- Facade/Alias Support Provide a "static" interface to classes that are bound to the Sage container.
- Blade Fixes Fixes Blade
@inject
directive and 5.5'sBlade::if()
method.
Requirements
This package is specifically built for Roots\Sage 9.0.0-beta.4
and above. It goes without saying that your development server needs to have Php 7.0
or greater as well.
Installation
You can install the package via composer:
Sage Xpress Setup
Add to your after_theme_setup
action in app/setup.php
file. It is important that you make this addition after Sage's singleton for the BladeProvider
:
Important Since this package is introducing new Blade directives, you should clear your cached/compiled Blade files. Those files are located in wp-content\uploads\cache
.
Configuration Files
Currently, you have to copy and paste the sample config files into your theme config
directory. You can find them in the vendor\webstractions\sage-xpress\config
directory.
The configuration files are a major component of SageXpress that drives the Providers (more below).
app.php
Registers theme environment, providers, composers, and aliases.blade-directives.php
For your custom Blade directives.comments.php
Comment form configuration. Other comments related tasks.menu.php
Register nav menus and configurations.sidebar.php
Register sidebars and configurations.
Overview
Outside of one line of code that you need to add to setup.php
and the config files, there is nothing else you need to do. Config files are automatically registered with the Sage Container, no messing with functions.php
.
Additionally, your setup.php
file should actually be leaner. No need for widgets_init
, register_nav_menus
, and funky wp_nav_menu
callouts in your controllers or blade files. The providers automatically do the registration for you based on your configurations and there are Blade Directives to spew them out.
Facades and Aliases
You can now register aliases
via the config\app.php
configuration file. Currently, there are standard Laravel Facades for Blade, Config, Event, File, and View. Facades for SageXpress providers are in a state of flux and currently supports Comments, Menu, and Sidebar.
With Facades, you can reference bound providers with unruly instantiation and method calls like the following.
Instead of
You can:
Facades have some advantages. Rather than list the pros and cons of Facades, and how they work, please reference the Laravel Facade Documentation.
The SageXpress Provider
SageXpress providers are similar to Laravel Service Providers, but they contain additional methods for config()
and render()
. You can think of them as configurable components that can be rendered in a Blade view.
Providers are autoloaded via the config\app.php
congifuration file during the SageXpress boot process. The providers are then bound to the Sage Container where you can use or reference them from your theme classes and controllers.
Providers handle WordPress-centric methods for registration, filters, etc. The render()
method can be used for the creation of custom Blade directives.
Blade Directives Provider
Provides some handy Blade directives targetted mostly for WordPress use, but other helpful functionality as well.
There are a whole slew of directives, and requires its own Blade Directives Documentation.
One example, the @loop
directive does a nice job of cleaning up your templates.
The directive will output this php.
Menu Provider
Configure your menus in config\menu.php
. The MenuProvider
will handle the registration with WordPress.
You can safely remove any configured menus from your setup.php
file.
Use @menu
directive in your Blade files to render a menu.
Alternatively, you can create a static rendering function in app\controllers\app.php
Then call the function in your Blade files.
Sidebar Provider
Configure your sidebars in config\sidebar.php
. The SidebarProvider
will handle the registration with WordPress.
You can safely remove any configured sidebars from your setup.php
file.
Use @sidebar
directive in your Blade files to render a menu.
Alternatively, you can still use WordPress functions to display a sidebar.
Comment Form Provider
Configure your comment form in config\comments.php
and use the @commentform
directive to display in your Blade templates.
The following shows an example configuration for Bootstrap 4 Beta markup.
Schema Provider
As with the Blade directives, there are numerous schema.org attributes and has its own documentaion. There are also two filters for each attribute, which can be used to extend them further. See Schema Provider Documentation for complete details.
Using the @schema
directive makes markup simple.
Will produce the following Php.
Documentation
Acknowledgements
- Roots/Sage Discourse thread Resources for Blade and Log1x's contributions for inspiring the Blade component.
- Appstract's Laravel Blade Directives for configuration and service provider logic.
- Justin Tadlock's
hybrid_attr()
functions from older versions of Hybrid Core.
License
The MIT License (MIT). Please see License File for more information.