Download the PHP package rjvandoesburg/laravel-nova-templating without Composer

On this page you can find all versions of the php package rjvandoesburg/laravel-nova-templating. 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 laravel-nova-templating

Add dynamic JS template loading to your Laravel Nova powered application

Let your Nova resources decide what front-end template needs to be loaded.

This package was inspired by WordPress template hierarchy.

This package will add an endpoint to your application and uses Nova to resolve the resource and associated model. The endpoint will return an array of names e.g. a hierarchy of templates that you can use in your front-end application to "dynamically" render a page.

Requirements

This package requires Laravel 5.8 or higher, PHP 7.2 or higher.

Installation

You can install the package via composer:

To add the endpoint, add the following to a routes file, you can apply your own groups & middleware as you see fit!

This will add /template-api/{resource}/{resourceId} to your application.

The package will automatically register itself.

Usage

Once the routes have been added to your application you can retrieve a list of template names from the api.

Because this is based on Laravel Nova the resource needs to be the same as generated by the Resource or what is defined in public static function uriKey(). resourceId is the ID of the model.

Which can return a result as followed:

Currently the packages constructs the template list as follows:

Note that resource is only present when the resource name differs from the model name.

VueJs

Say you want to use this within Vue, here is an example of how you could implement this:

From app.js I am loading all files within the templates folder and prefixing template as the name when registring them with Vue.

Create a Vue file that will be rendered on specific routes. In the example I am using vue-router and beforeRouteEnter to retrieve the correct template based on the current url.

Disable resource templating

So everything is up an running, using a wildcard for routing, but you don't want people to access certain models. You can disable (enabled by default) templating for certain resources by implementing the following interface: Rjvandoesburg\NovaTemplating\Contracts\Templatable. This will add the method isTemplatable(Request $request) where you can add your own logic to decide if the given resource is templatable.

Dealing with failures

When a resource cannot be found or an exception is thrown a json response is returned (with the error status code) containing error template names with a fallback on index.

Within the Promise you can still access the response from a catch so it is up to you to decide how to handle the error.

TODO

Contributing

Please see CONTRIBUTING for details.

Credits

Special thanks for Spatie for their guidelines and their packages as an inspiration

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-nova-templating with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
laravel/framework Version ~5.8||^6.0
laravel/nova Version *
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 rjvandoesburg/laravel-nova-templating contains the following files

Loading the files please wait ....