Download the PHP package coder-at-heart/object-models without Composer

On this page you can find all versions of the php package coder-at-heart/object-models. 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 object-models

A handy way to define, use and convert object and arrays to json

This Laravel package:

Requirements

This package requires

Installation

Install it:

Defining ObjectModels

Extend the ObjectModel class and extend override the properties() method

I usually create an app/ObjectModels folder to store my models

Here's an example from the tests folder:

And the Address

The Country ENUM

And the Phone:

Note the use of the docBlock at the top of the classes - this helps with type hinting in your ide.

Instantiating Objects

Can be done through arrays, json or directly

ArrayModels

You don't need an Object Model to use an Array Object:

Casting eloquent model attributes and json columns

You can use ObjectModels and ArrayModels when creating custom casts in your app - Especially useful when casting json columns.

ObjectsModels:

And ArrayModels:

Built-in Property Types

Type Create With Underlying Object
Another Model Property::objectModel(); ObjectModel
Bool Property::bool(); php bool
Date Property::date(); Carbon
DateTime Property::dateTime(); Carbon
ENUM Property::enum(); php ENUM
Email Property::email(); php string
Float Property::float(); php string
Integer Property::integer(); php integer
Strings Property::string(); php string
Time Property::time(); Carbon
an Array Property::array(); php array
an Array of other models `Property::objectModelArray(); arrayModel
an Array of property `Property::propertyArray(); arrayModel
an Object Property::object(); the Object
mixed Property::mixed(); any

Custom Property Types

Extend the Property class to add in your own propertires.

The two main callbacks are jsonCallback called when the property is going to be turned into json, and setCallback when the property is assigned a value.

Here's an object using Custom properties

Object Validation

Object and Arrays can be validated. What you get back is a ObjectValidation Object

Note: ObjectModels or ArrayModels are not validated automatically.

Adding Rules

When you're defining object you can add any valid laravel validation rules

You can get rules on an objectModel using $person->getRules()

Ignoring undefined properties

By default ObjectModels throws an exception if you try and set a property that hasn't been defined.

Get around that by using the IgnoreUndefinedProperties trait

Got an idea / Suggestion / Improvement?

Let me know... somehow.

Support

License

ObjectModel is licensed under the MIT License.

v1.1.14


All versions of object-models with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
nesbot/carbon Version ^2.61
illuminate/support Version ^10.0 || ^9.0 || ^10.0
illuminate/validation Version ^8.0 || ^9.0 || ^10.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 coder-at-heart/object-models contains the following files

Loading the files please wait ....