Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Accessible Laravel Package

antares/accessible

View on GitHub
Deep Wiki
Context7

Accessible

SensioLabsInsight Build Status Code Coverage Scrutinizer Code Quality Dependency Status Latest Stable Version License

Accessible is a PHP library that allows you to define your class behavior in an elegant and powerful way using docblock annotations.

This way, you can define your class' getters, setters and constructor, and automate collections and association management.

Here is a (very) basic example with getters and setters:

class Customer
{
  use AutomatedBehaviorTrait;

  /**
   * @Access({Access::GET, Access::SET})
   * @Assert\Email
   */
  private $email;
}


$bob = new Customer();

$bob->setEmail('bob@example.com');
$bob->getEmail(); // bob@example.com
$bob->setEmail('not an email address'); // throws an InvalidArgumentException

Another example using collections related annotations:

class Server
{
  use AutomatedBehaviorTrait;

  /**
   * @Access({Access::GET})
   * @InitializeObject(ArrayCollection::class)
   * @ListBehavior
   */
  private $processes;
}

$server = new Server();

$server->getProcesses(); // Instance of ArrayCollection
$process = new Process();
$server->addProcess($process);
$server->removeProcess($process);

More complex examples are available in the doc.

What this library can manage in your classes:

  • Getters and setters
  • Validation on setters parameters using Symfony's Assertion annotations
  • Constructor and properties initialization
  • Collections
  • Associations between classes

Suggestions and contributions are welcome!

Documentation

Install

If you want to use this library in your Symfony project, take a look at AccessibleBundle.

You can add this library as a dependency using composer this way:

composer require antares/accessible

This library uses the Doctrine annotations library, so if it is not already done you must register the Composer loader in the annotation registry:

$loader = require __DIR__ . '/vendor/autoload.php';
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

You may want to change the default configuration, to do this see the Configuration dedicated page.

Compatibility

This library is compatible with PHP 5.4+, PHP 7 and HHVM.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui