Download the PHP package rougin/weasley without Composer

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

Weasley

Latest Version on Packagist Software License Build Status Coverage Status Total Downloads

Weasley is a PHP package that provides generators, helpers, and utility classes for the Slytherin. Its goal is to improve the overall productivity when writing web applications based on Slytherin by reducing in writing code related to CRUD operations.

Installation

Install Weasley through Composer:

Basic usage

Weasley is built on a layered architecture where each domain delegates to a dedicated package:

Package Purpose
Slytherin Simple, extensible PHP micro-framework.
Onion HTTP middlewares for Slytherin.
Valla A simple validation package in PHP.
Blueprint A bootstrap for PHP console projects.
Classidy Create PHP classes using PHP.

Code generators

Weasley provides commands that generate code for Slytherin components. These commands allow Slytherin to be a rapid prototyping tool when creating web-based applications.

Use the weasley command to access the list of its available commands:

Available commands

Command Description
make:check Creates a new validation (Check) class
make:handler Creates a new HTTP Middleware class
make:package Creates a new Slytherin Integration class
make:route Creates a new HTTP route class

Each command accepts the following options:

Option Default Description
--path src/Checks Directory where the file will be created
--namespace App\Checks Namespace for the generated class
--author (empty) Author name in the class docblock

HTTP routes

Weasley provides classes for creating HTTP routes in the RESTful style. In other PHP frameworks, these are also known as Controllers.

HttpRoute

A simple HTTP route class that provides a json() helper for returning JSON responses:

The Route class is a root-namespace alias for Rougin\Weasley\Routes\HttpRoute. It accepts the PSR-07 request and response through its constructor:

JsonRoute

Extends HttpRoute with built-in CRUD operations backed by an Eloquent model and a validator:

Once defined, the following methods become available:

Method HTTP Equivalent Description
index() GET /users Returns all records (paginated when illuminate/pagination is installed)
show($id) GET /users/{id} Returns a single record
store() POST /users Creates a new record from the parsed request body
update($id) PUT /users/{id} Updates an existing record
delete($id) DELETE /users/{id} Deletes a record

The $model must be an Eloquent model with $fillable defined. The $validator must be a Check subclass. Both are validated at construction time and will throw UnexpectedValueException if missing.

HTTP handlers

Weasley provides HTTP middlewares (handlers) that process incoming requests and outgoing responses. Each handler implements Rougin\Slytherin\Middleware\MiddlewareInterface.

[!NOTE] Starting v0.8, all handler classes are thin wrappers over Onion (rougin/onion). Every feature described below originates from Onion's classes.

AllowCrossOrigin

Adds CORS headers to every response:

[!NOTE] If the incoming request method is OPTIONS, the handler returns an empty response immediately (preflight support).

EmptyStringToNull

Converts empty, "null", and "undefined" string values from query parameters and parsed body to actual null:

JsonContentType

Sets the Content-Type header to application/json on every response that does not already have one:

MutateRequest

An extensible base class for transforming request values. Extend it and override the transform() method:

The transform() method is called recursively on every value in query parameters and the parsed body. Arrays are recursed into automatically.

SpoofHttpMethod

Replaces the HTTP verb of the request with the value of a configurable key from the parsed body, enabling HTML forms to simulate PATCH, PUT, or DELETE:

When the request body contains ['_method' => 'PATCH'], the request method becomes PATCH.

TrimStringValue

Trims whitespace from all string values in query parameters and the parsed body:

Validation

Weasley provides the Check class for validating data. It is built on Valla (rougin/valla) and supports all rules from Valla's rule engine (e.g., required, email, and more):

Error messages are built from the label and the rule description. For example, a missing email field with the label "Email" produces "Email is required".

Method-based style (recommended)

The method-based style is recommended when rules depend on the submitted data (e.g., conditionally requiring a field):

Property-based style (legacy)

This can also define rules and labels as protected properties for simple, static rule sets:

Mutators

Mutators transform data into a specified output format (e.g., PSR-07 responses, API payloads). They implement Rougin\Weasley\Contract\Mutator.

JsonMutator

Encodes data as JSON and returns a PSR-07 response:

A second argument accepts JSON encoding options:

RestMutator

Formats paginated results following PayPal's API Style Guide:

When the data is not a LengthAwarePaginator, the mutator wraps it as ['items' => $data].

Third-party packages

Weasley provides IntegrationInterface implementations for wiring third-party packages into Slytherin's container.

Laravel\Eloquent

Enables Eloquent ORM from Laravel:

Laravel\Blade

Enables Blade templating:

Laravel\Paginate

Adds pagination support to Eloquent models:

Session

Provides session management through SessionHandlerInterface:

Contracts

Weasley defines interfaces for its extensible components:

Contract\Mutator

Implement this interface to create custom mutators. JsonMutator and RestMutator are built-in implementations.

Contract\Session

Utilities

Random

Generates cryptographically secure random strings:

Changelog

Please see CHANGELOG for more recent changes.

Upgrade Guide

As Weasley continues to evolve, there might be some breaking changes in its internal code during development. The said changes can be found in UPGRADING.

Contributing

See CONTRIBUTING on how to contribute.

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of weasley with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
rougin/slytherin Version ~0.9
vlucas/valitron Version ~1.4
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 rougin/weasley contains the following files

Loading the files please wait ...