Download the PHP package buzzingpixel/corbomite-http without Composer

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

Corbomite HTTP

Part of BuzzingPixel's Corbomite project.

Provides a light framework for responding to HTTP requests.

Usage

In your HTTP front controller, use the dependency injector to call the Kernel (note that APP_BASE_PATH can optionally be defined as a constant and must be where your vendor directory resides. Otherwise the path to your vendor directory will be figured out automatically).

Kernel Method Arguments

The Kernel can receive up to two arguments.

If the first argument is an array, the second argument will be ignored, and the first argument as an array must send class names or class instances as values of the array that implement \Psr\Http\Server\MiddlewareInterface. These classes will be added to the middleware stack after any error handlers are added (and after the CSRF middleware if that's not disabled) and before Corbomite HTTP's Action params and routing.

If the first argument is a string or a class, it must implement \Psr\Http\Server\MiddlewareInterface and will be added as the error handler if the environment variable DEV_MODE is not set to a string of true. The second argument then can be an array of middleware as above.

Error Handling

If the environment variable DEV_MODE is set to a string of true, the Kernel will attempt to set PHP error output to maximum and add \Franzl\Middleware\Whoops\WhoopsMiddleware as the first item to the middleware stack. In this way, as you develop, you can get whatever information and trace you need over your HTTP stack when an error is encountered.

If not in dev mode, and if you've provided a middleware to handle errors as described above, then your provided error middleware will be the first thing added to the middleware stack. In this way, you have a chance to render error pages in your app in production.

If you send a string class name, the Kernel will attempt to get the class from the supplied ContainerInterface implementation and fall back to newing up the class.

Here's an example of an error handler middleware class:

CSRF Protection

By default, Corbomite HTTP adds CSRF PSR-15 Middleware to the middleware stack to prevent cross-site forgery on post requests.

Sometimes, it may be desirable to have certain segments that are exempt from CSRF middleware. If you wish to disable the middleware for certain segments, you can define a config for the disabled segments in your composer.json extra object:

You can also disable the CSRF middleware altogether in the JSON extra object like so:

Or you can disable it only when in dev mode:

Routing

Corbomite HTTP uses FastRoute for routing. Your app or any composer package can register routes by providing a httpRouteConfigFilePath in the extra composer.json object.

The called route file will have a variable available by the name of $routeCollector (and a shortcut variable of $r if you prefer brevity). Here's an example route file:

ActionParams

Action params are available as either query params /some-uri?action=myAction on get requests or as post body params on post request action=someAction.

Actions are processed before routes and are great for handling, say, post requests and if the post request does not validate, then the route will continue to process. If the post request does validate, you could redirect to a new page or return a response of some kind.

In order to request an action, action config will need to be set up. Your app or any composer package can define an action param config file in the extra object of composer.json with the httpActionConfigFilePath key:

The action config file should return an array of actions like so:

Disabling Action Params

You can also disable action params altogether in the JSON extra object like so:

Twig Extension

Corbomite HTTP provides a Twig extension. If you're using Corbomite Twig this extension will be loaded automatically. Otherwise, you can add it to your own Twig instance Twig's addExtension() method like this:

{{ throwHttpError() }}

This twig function is for throwing an HTTP error from Twig. The default is to throw the 404 exception. Pass 500 in as an argument throw a 500 internal server error.

{{ getCsrfFormKey() }}

Gets the form key name for the CSRF token.

{{ generateCsrfToken() }}

Generates and outputs a CSRF token.

{{ getCsrfInput() }}

Outputs a hidden input for the CSRF token.

License

Copyright 2019 BuzzingPixel, LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


All versions of corbomite-http with dependencies

PHP Build Version
Package Version
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 buzzingpixel/corbomite-http contains the following files

Loading the files please wait ....