Download the PHP package vedmant/laravel-shortcodes without Composer

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

Laravel Shortcodes

Latest Version on Packagist Total Downloads Tests StyleCI

Wordpress based Shortcodes for Laravel Framework with shared variables, debugbar integration, flexible configurations and other useful features.

Build powerful and simple layouts using shortcodes in the content or views like this:

Installation

Via Composer

Configuraton

Publish configuration.

It will publish configuration file shortcodes.php, edit it as needed.

Usage

Shortcode class

Shortcode class should extend abstract \Vedmant\LaravelShortcodes\Shortcode class.

This packages adds the make:shortcode artisan command:

Which generates a shortcode class in the app/Shortcodes folder by default.

Register shortcodes

You can use AppServiceProvider::boot method to register all needed shortcodes.

Using shortcode class:

Using shortcode classes in array, preferable for lots of shortcodes:

Using closure:

Render shortcodes

Views auto-render

By default this package extends the View class to parse all shortcodes during views rendering. This feature can be disabled in the config file: 'render_views' => false. For better performance with lots of views it's advised to disable views auto-render.

Enable / disable rendering per view

Also to enable / disable rendering shortcodes for a specific view you can use:

Render shortcodes with the facade

Render shortcodes with blade directive

Render shortcodes with shortcodes() helper

Shared attributes

Occasionally, you may need to share a piece of data with all shortcodes that are rendered by your application. You may do so using the shortode facade's share method. Typically, you should place calls to share in the controller, or within a service provider's boot method.

Then you can get shared attributes in the shortcode class:

Attribute casting

The $casts property on your shortcode class provides a convenient method of converting attributes to common data types. The $casts property should be an array where the key is the name of the attribute being cast and the value is the type you wish to cast the column to. The supported cast types are: int, integer, real, float, double, boolean, array (comma separated values) and date.

Now the show_ids attribute will always be cast to an array when you access it. (array attributes are casted from comma separated string, eg. "1,2,3").

Attribute validation

There is a simple way to validate attributes. Error messages will be rendered on the shortcode place. For convenients it will return attributes.

Option to not throw exceptions from shortcodes

There is a useful option to aviod server (500) error for whole page when one of shortocode has thrown an exception.

To enable it set 'throw_exceptions' => false, in the shortcodes.php config file.

This will render exception details in the place of a shortcode and will not crash whole page request with 500 error. It will still log exception to a log file and report to Sentry if it's integrated.

Generate data for documentation

There can be hundreds of registered shortcodes and having a way to show documentation for all shortcodes is quite a good feature. There is simple method that will collect descriptions and attributes data from all registered shortcodes:

It returns Collection object with generated data that can be used to generate any help information.

Integration with Laravel Debugbar

This packages supports Laravel Debugbar and adds a tab with detailed info about rendered shortcodes. Integration can be disabled in the config file with option: 'debugbar' => false,.

Testing

TODO

  1. Add custom widget for debugbar integration
  2. Create performance profile tests, optimize performance

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.


All versions of laravel-shortcodes with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
illuminate/contracts Version >=5.5.0
illuminate/view Version >=5.5.0
illuminate/support Version >=5.5.0
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 vedmant/laravel-shortcodes contains the following files

Loading the files please wait ....