mirror of
https://github.com/archtechx/livewire-access.git
synced 2025-12-12 04:14:03 +00:00
initial
This commit is contained in:
parent
a29235253b
commit
e50e22434f
12 changed files with 159 additions and 138 deletions
41
README.md
41
README.md
|
|
@ -1,17 +1,50 @@
|
|||
# Package
|
||||
# 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*.
|
||||
|
||||
Components which implement the trait provided by this package will implicitly deny access to all properties and methods if they don't have the `#[FrontendAccess]` attribute, regardless of their visibility.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
composer require stancl/package
|
||||
composer require leanadmin/livewire-access
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```php
|
||||
// ...
|
||||
use Livewire\Component;
|
||||
use Lean\LivewireAccess\WithExplicitAccess;
|
||||
use Lean\LivewireAccess\FrontendAccess;
|
||||
|
||||
class MyComponent extends Component
|
||||
{
|
||||
// Use the trait on your component to enable this functionality
|
||||
use WithExplicitAccess;
|
||||
|
||||
// Accessing this from the frontend will throw an exception
|
||||
public string $inaccessible;
|
||||
|
||||
#[FrontendAccess]
|
||||
public string $accessible; // This property allows frontend access
|
||||
|
||||
public function secretMethod()
|
||||
{
|
||||
// Calling this from the frontend will throw an exception
|
||||
}
|
||||
|
||||
#[FrontendAccess]
|
||||
public function secretMethod()
|
||||
{
|
||||
// This method allows frontend access
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The properties still need to be `public` to be accessible.
|
||||
|
||||
The thrown exceptions are identical to those that Livewire would throw if the properties/methods were not public.
|
||||
|
||||
## Development
|
||||
|
||||
Running all checks locally:
|
||||
|
|
@ -23,8 +56,6 @@ Running all checks locally:
|
|||
Running tests:
|
||||
|
||||
```sh
|
||||
MYSQL_PORT=3307 docker-compose up -d
|
||||
|
||||
phpunit
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue