Download the PHP package emant/brownie-php without Composer

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

BrowniePHP

A Tiny PHP Routing Framework

BrowniePHP is a lightweight PHP routing framework, inspired by Express.js, that provides a simple and intuitive way to handle HTTP requests and define routes for your web applications. It aims to be minimalistic yet powerful, allowing you to quickly build RESTful APIs or handle various HTTP methods with ease.

Features

Installation

You can install BrowniePHP using Composer. Run the following command in your project directory:

Getting Started

To define a route, create an instance of the Router class and use the appropriate method based on the desired HTTP method:

You can add global middleware functions using the use method:

The Router class provides an all method, which allows you to define a route that matches all HTTP methods. This means that any incoming request, regardless of the HTTP method used, will be matched. It provides a convenient way to handle common functionality or apply middleware , regardless of the specific method.

To start the routing process, call the run method:

This will match the incoming request to the defined routes and execute the corresponding route handler or middleware functions.

Inside the route handler or middleware functions, the request context is available as an associative array named $ctx. You can access various request properties such as method, path, query parameters, request body, and headers through this array.

Mounting a Nested Router

The all method provided by the Router class allows you to mount a nested router on a specific path. This is useful when you want to group related routes together under a common prefix or when you want to delegate the handling of certain routes to a separate router instance.

To mount a nested router, follow these steps:

  1. Create an instance of the nested router using the Router class constructor.

  2. Mount the nested router on a specific route of the main router using the all method.

  3. Run the main router to start processing incoming requests.

Utils Class

The Utils class in BrowniePHP provides a collection of utility methods that offer functionality commonly used in web development. Here are some key methods available in the class:

send_json($data)

This method sends JSON-encoded data as a response to the client. It supports JSONP by checking for a callback parameter in the request URL. If the parameter is present, the response is wrapped in a callback function. Otherwise, the response is sent as standard JSON. This method can be used to send JSON data back to the client in a consistent and structured manner.

enable_cors($origin = '*')

This method enables Cross-Origin Resource Sharing (CORS) by setting the necessary headers in the response. It allows requests from different origins to access the resources of your application. The $origin parameter specifies the allowed origin or origins. By default, it is set to '*', allowing requests from any origin. The method sets the Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Headers, and Access-Control-Allow-Methods headers accordingly.

Error Handlers

The Utils class also includes error handler methods that simplify the process of returning error responses. These methods facilitate sending error messages and appropriate HTTP status codes to the client.

server_error($error_type, $description, $status_code)

This method generates an error response with a specified error type, description, and HTTP status code. It constructs an associative array with the error details and sets the appropriate status code. The error response is then sent as JSON using the send_json method.

unknown_error()

The unknown_error method is a convenience wrapper for the server_error method. It simplifies handling internal server errors by providing a pre-defined error type, description, and HTTP status code.

not_found()

Similar to the unknown_error method, not_found is a convenience wrapper for the server_error method. It simplifies handling resource not found errors by providing a pre-defined error type, description, and HTTP status code.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

BrowniePHP is open-source software licensed under the MIT license.


All versions of brownie-php with dependencies

PHP Build Version
Package Version
Requires ralouphie/mimey Version ^1.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 emant/brownie-php contains the following files

Loading the files please wait ....