Download the PHP package leanadmin/livewire-access without Composer

On this page you can find all versions of the php package leanadmin/livewire-access. 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 livewire-access

Livewire Access

This package adds PHP 8.0 attribute support to Livewire. In specific, the attributes are used for flagging component properties and methods as frontend-accessible.

The package ships with two pairs of traits and attributes. One for explicit access, and one for implicit access.

How it works

This acts as a layer on top of Livewire's public-check logic, but gives you much more fine grained control.

Why use this?

Sometimes, you may want allow access to a component's property in PHP — outside the component — while not allowing access from the frontend. For that, you can use the WithImplicitAccess trait. Frontend access will be enabled for all properties by default, but you can disable it for a specific property (or method).

Other times, you may simply want more assurance than Livewire provides out of the box. The WithExplicitAccess trait is made for that. It disables all frontend access, and requires you to manually enable it on specific properties/methods.

The second option is recommended, because it provides the most security benefits. Accidentally making methods public is common, and it can cause security issues. Disabling implicit access can be especially useful on teams with junior engineers who don't yet have a full understanding of Livewire's internals, but can be very productive with it.

Practical use case

Say you have a component with the following method:

In the Blade template, you want to loop through the items and only display the non-secret ones.

However, the entire dataset will be accessible from the frontend, even if you're not rendering any of the secret items.

The user can easily fetch the Livewire component in Developer Tools and make a call like this:

It will return all of the data returned by the getItemsProperty() method in PHP.

Screen Shot 2021-03-17 at 21 53 00

You may think that in this case, you should just make the method protected/private. However, that would make it inaccessible from the Blade template. Even though Livewire uses $this in the template, it's accessing the object from the outside.

Which means that although Blade templates are completely server-rendered, and let you access any PHP code in a secure way, you cannot access many of the properties or methods of Livewire components without making them public, which can cause unexpected data leaks.

With this package, you can keep the property public and access it anywhere in PHP, while completely blocking any attempts at accessing it from the frontend.

Installation

PHP 8 is required.

Usage

This package doesn't make any changes to your existing code. Components which don't implement either one of its traits will not be affected.

Explicit access

To enable the explicit access mode, i.e. only enable access to properties/methods that explicitly allow it, use the WithExplicitAccess trait.

Implicit access

To enable the implicit access mode, i.e. keep using the same mode , use the WithExplicitAccess trait.

Details

Development

Running all checks locally:

Running tests:

Code style will be automatically fixed by php-cs-fixer.


All versions of livewire-access with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
livewire/livewire Version ^2.10
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 leanadmin/livewire-access contains the following files

Loading the files please wait ....