Download the PHP package summerstreet/woodling without Composer

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

Woodling

Latest Stable Version Total Downloads Build Status

Easy to use fixtures for your models. Requires no configuration on your side, leverages your code to do all the work.

Installation and initialization

You can install Woodling via Composer. Put this in your composer.json file and run $ composer update --dev:

You don't need to do anything else. Woodling will be automatically loaded for you when you first use it.

Defining blueprints

Blueprints are used to construct an instance of your specified model. Woodling guesses which model class you want to use from the name you give your blueprint.

The following code will return an instance of User class with name attribute set to "John Doe" and hobbies attribute set to "Unit Testing".

You can also specify a different class name by passing it in with an array of arguments. This will create a blueprint called "Admin" and use class "User" when creating an object:

By the way, since Woodling utilises your code, you can take advantage of everything that your classes do under the hood. For example, if you were using Laravel's Eloquent, and your model would have a setPassword() mutator defined, this method would be called when setting your password.

Autoloading blueprints

Woodling will automagically load your blueprints defined in following locations:

You can also add additional search paths. In your bootstrap file add the following lines:

When adding paths, keep in mind, that the last segment of the path will be used as both file name and dir name:

Retrieving blueprints

To retrieve instances of your models, you can use the following methods:

The retrieve() method will return an instance of your class. The saved() method will create an instance of your class and call the save() method on it before returning it.

If your class uses a different method name for persisting, you can change it like this:

This will call mySaveMethod() when you are retrieving saved instances of your class.

Retrieving blueprints with attribute overrides

Sometimes you need to retrieve your models with slightly different attributes than the ones you specified in your blueprint. You can do so by passing an array of key => value pairs where key is the name of the attribute you want to override.

Retrieving lists

You can also retrieve an array of several instances instead of a single result. Woodling provides two build strategies for you: retrieveList() and savedList(). Here's how to use them (attribute overrides are optional):

Lazy attributes

If you want to calculate your attribute values during instantiation time, you can do so with lazy attributes. Just assign a closure to your attribute. The value returned from the closure will be the value used when setting this attribute on your model.

Sequences

Very often you have validation rules on your models or in the database that require you to use unique values. If that is the case, you can use sequences. A sequence takes a closure, which receives a counter value. You can then use this counter to construct a unique value for your model.

Each time you retrieve an object, it's counter will be incremented. The following code will set an email attribute on your model. The first time you retrieve this object, it will receive a counter value of 1, the second time your retrieve it, counter will be 2 and so on.

Faux associations

It is possible to create model associations by returning them from lazy attributes. This is how you'd retrieve an instance with one-to-one relationship from Woodling:

And this is how you'd do the same for one-to-many:

Retrieving blueprints with advanced overrides

You can override lazy attributes by passing them in as a regular callback function that returns something. To override sequences, you can put them under :sequences array:

More awesome usage

Here's an example that shows how to use sequences and lazy attributes to create more realistic model instances.

Free tip

Don't forget to put use Woodling\Woodling; at the top of your file. This will let you use short class syntax instead of having to prepend it with a namespace.

License

For license information, check the LICENSE file.


All versions of woodling with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 summerstreet/woodling contains the following files

Loading the files please wait ....