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.

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-stacked-components

Latest Stable Version Total Downloads License

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.

Requirements

For Laravel 10 and 11, use version 0.10.

Installation

To customize the config, publish it to :

Every config value can also be set by an environment variable named plus the config key in upper snake case, like for .

Upgrading from 0.x? See UPGRADE.md.

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 to stay closer to HTML whenever possible.

The Stacked Components way

JS component

or, for inline JS:

Any other attribute, like or , goes to the tag.

CSS component

pushes . For inline CSS:

pushes a tag. Any other attribute, like , goes to the tag, and and can be overridden.

A component can't have both a and inline code.

The asset function

This package calls Laravel's function on the of the JS and CSS components by default. You can override this behavior to call your own callable or to call nothing at all. To do either of these, you can set the environment variable

or the config value

or, for a single component, the attribute:

The asset function can be any PHP callable or use Laravel's "@" syntax (). The callable is invoked through Laravel's container, which passes the asset's src to its parameter and injects any other dependency it asks for. Global functions with no parameter, like Laravel's , get the src as their first argument instead. To call no function, set the config value or the environment variable to false.

Note that if you use objects (anonymous 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:

It pushes its content as is.

Div component

pushes its content wrapped in a with the given attributes.

Stack options

All the components accept:

Both take a string (), a bound bool () or no value (, meaning true):

Default stacks

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:

The head_bottom stack

Every template with a tag gets a stack right before it, so you can push to the end of without declaring a stack in your layout:

To turn it off, set the config value or the environment variable to false, and clear the view cache: templates get the stack when they're compiled.

Resolving name collisions with other components

If your app, or a library you're using, already defines components with the same names as this package's, 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 to , it will use the namespace "stacked", as in . If you set it to any string, that 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 components.

Remember to clear the views caches when changing any of these values. To clear the view cache run the view:clear artisan command:

Extending the components

You can extend the component classes, but their protected methods and properties are internal: they aren't part of the package's API and may change in any release. Extend them at your own risk.

License

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


All versions of laravel-stacked-components with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^12.0|^13.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 erickcomp/laravel-stacked-components contains the following files

Loading the files please wait ...