Download the PHP package erickcomp/laravel-stacked-components without Composer
On this page you can find all versions of the php package erickcomp/laravel-stacked-components. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-stacked-components
Use Blade Components syntax to insert (push/prepend) content to stacks
This package provides some blade components that you can use to insert content into stacks, most notably, scripts and styles.
The vanilla-Blade way
To push some JS file/code to a stack, you have to (from Laravel docs):
or, for inline JS:
It, of course, works. But when using Blade Components, the intention is stay closer to HTML whenever possible
The Stacked Components Ways
JS component:
or, for inline JS:
This package automatically calls Laravel's function by default. You can override this behavior to call you own callable or to call nothing at all. To do either of these, you can set the environment variable
or the config value
To call any callable, you can use one of the following options the PHP's callable syntax or the Laravel's "@" syntax (). To call no function by default you must set the config value or the environment variable with the value false.
Note that if decide to use objects (anonoymous functions, invokable objects, first-class callables), you won't be able to use Laravel's config cache, since it does not support cache for these types of config values.
Content component:
or, for inline JS:
Other components
This package provides 4 components
- js
- css
- stacked-div
- stacked-content
For the CSS and JS components, you can set a default stack in config/env and omit it when using the component, like this:
.env file:
and in your view file:
Resolving name collisions with other components
This package provides the js and the css components. If your app already defined this, or even a library you're using did this, you have 2 options:
1 - Register a namespace for the components of this package. To do so, you can set the environment variable
or the config value
If you set the namespace with the bool value "true", it will use the namespace "stacked". If you set it to any string, the set string will be used as the blade components namespace. For more information on components namespaces check the Laravel docs
2 - Set the config values
or the environment variables
To specify alternate names for the js and css components
Remember to clear the views caches when changing any of these values. To clear the view cache run the view:cache artisan command:
License
The MIT License (MIT). Please see License File for more information.