Download the PHP package gugglegum/abstract-entity without Composer

On this page you can find all versions of the php package gugglegum/abstract-entity. 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 abstract-entity

Abstract Entity Class

This class is used as a base class for classes with entities (models). An entities extended from this base class will get the methods to work with attributes through getters and setters. The constructor method allow to pass an array which will be used to initialize new object. It also contains getGetter() and getSetter() methods to convert an attribute name to getter and setter methods. For every entity class property (which should be private) you need to generate a pair of getter and setter. You may use automatic generation of these methods in your IDE (I use the PhpStorm).

The abstract entity gets a list of attributes of concrete entity from its properties (using ReflectionClass). You may redefine this method to add some additional handling. You may add some virtual attributes which are not present as class properties or remove some special properties which should not be used as attributes.

Release notes for version 1.1.0

This minor version update contains many awesome improvements. The most important thing is that I found a bug in previous versions related to static variable inside class methods getAttributeNames() and hasAttribute(). They were used to cache list of entity attributes which are initially retrieved via \ReflectionClass from all parent classes. This is potentially slow operation, this is why I cached them on class level. But these static variables may result unexpected behavior if static variable in parent class initialized before child class was loaded, i.e. reproducing of this error is related to the order your classes are loaded and used. And usually you don't control this order due to use of class auto-loaders. This is why it was hard to debug this error.

I had some suspicions about it, I started to write unit tests to cover all code. First time all was looking good, so I calmed down a little. But then it broke in a very unexpected place. It was a result of unit test execution in some special order. PHPUnit executes all tests in one system process, so first tests may affect latest tests. I investigated this and made a special tests for reproducing this bug.

Then I used these tests to ensure that bug completely fixed. I decided to completely refuse static variables inside class methods as they are very unpredictable and can't be controlled in some cases. Now I use class static properties with 2-dimension array where first level is name of concrete model class.

Also there's some other improvements:

Requirements

This class written to be executed on PHP version 7.0 or better. It uses define(strict_types=1) and scalar types in methods definition.

Example

An entity class example:

Test usage:

If you would like to use your own exception class in your models, the best solution is to define it in the constructor of your models. But note that you should set exception class prior to call parent::__construct($data) because parent constructor may throw an exceptions.


All versions of abstract-entity with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.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 gugglegum/abstract-entity contains the following files

Loading the files please wait ....