Download the PHP package spatie/laravel-view-components without Composer

On this page you can find all versions of the php package spatie/laravel-view-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-view-components

THIS PACKAGE HAS BEEN ABANDONED

A better way to connect data with view rendering in Laravel

Latest Version on Packagist GitHub Workflow Status StyleCI Quality Score Total Downloads

View components are a way to help organize logic tied to view, similar to view composers.

A view component can be anything that implements Laravel's Htmlable contract, so you don't necessarily need to use Blade views to render the component. This is useful for wrapping third party HTML packages, like spatie/laravel-menu.

The benefit over view composers is that data and rendering logic are explicitly tied together in components instead of being connected afterwards. They also allow you to seamlessly combine properties and dependency injection.

This package is based on Introducing View Components in Laravel, an alternative to View Composers by Jeff Ochoa.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

No additional setup necessary. Laravel will automatically discover and register the service provider.

Optionally you can publish the config file with:

This is the default content of the file that will be published at config/view-components:

Usage

The @render directive

The @render Blade directive accepts two arguments: the first is the view component's path or class name, the second is an extra set of properties (optional).

You can choose between referencing the component via a path or a class name.

Parameters will be injected in the view components __construct method. The component is instantiated with Laravel's container, so parameters that aren't provided by render will be automatically injected.

In the above example, $color is explicitly set, and a $request object will be injected by Laravel.

Configuration

The root namespace

By configuring root_namespace, you can define where the bulk of your view components are located. By default, this is in App\Http\ViewComponents.

The above components can be rendered with @render('myComponent') and @render('nested.nestedComponent').

Additional namespaces

You can register additional namespaces in the namespaces configuration, similar to view paths.

The above Menu component can now be rendered with @render('navigation::menu').

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

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


All versions of laravel-view-components with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
illuminate/support Version ^6.18|^7.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 spatie/laravel-view-components contains the following files

Loading the files please wait ....