Download the PHP package depotwarehouse/toolbox without Composer
On this page you can find all versions of the php package depotwarehouse/toolbox. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package toolbox
Depotwarehouse.net Toolbox
This is a standard library of tools that abstracts common work needed to be done across all projects.
Database Management
There are a couple of classes that make working with databases easier in projects. This is designed for use with Laravel, as they expose Eloquent models, however Laravel is not strictly necessary. The repository pattern
allows for greater testability and easier to understand controllers. In your projects, simply create repositories that
extend from ActiveRepositoryAbstract
. For typehints you can use the contract ActiveRepository
.
The active repository requires a Validator
class to validate data processed within - this class is passed in via the constructor.
You should either create your own validator implementing the Validator
contract, or you can typehint the NullValidator
to perform no validation on the model whatsoever.
Validators are simple to implement. They were designed with Laravel validators in mind. They exceptions they throw, ValidationException
s, can be passed a failing Laravel Validator to construct an instance.
To implement a validator, simply make a class that implements the Validator
interface. The two methods should do nothing if validation passes and throw a ValidationException
if an error occurs.
Strings
Commonly projects have string related needs that aren't easily filled by the PHP standard library.
Strings\generateRandomString($length = 40)
This generates a random (pseudorandom, do not use this for cryptographic or security purposes) string of the given length. The convenient usage for this is generate noninteger keys for a database table.
Strings\starts_with($haystack, $needle)
Strings\ends_with($haystack, $needle)
Laravel Integration
Errors Partial
This project ships with an Error Partial that displays errors, warnings and success messages at the top of the application page, based on a consistent format. To Install the Error Partial Handler in a Laravel application, add
to your config/app.php
in the providers array. Next, you'll need to publish the view file with:
Now in your layout page, where you want the errors to appear (likely at the top), simply add
Now errors, warnings and success messages will consistently render!
Testing
All versions of toolbox with dependencies
illuminate/support Version ^5.3
illuminate/database Version ^5.3
illuminate/validation Version ^5.3