Download the PHP package phpwatch/fast404 without Composer

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

Fast 404

Quickly terminate an HTTP request with a 404 Not Found response for static resources.

Latest Stable Version CI Total Downloads License

phpwatch/fast404 is a library/middleware that you can to quickly terminate an HTTP request with a 404 Not Found response. The use case is a framework that handles all HTTP requests via a router, and returning a quick 404 message to static resources such as .jpg or .png. This prevents the framework from initializing rendering engines, database connections, etc to serve these types of requests.

The use case is a framework that handles all HTTP requests via a router, and returning a quick 404 message to static resources such as .jpg or .png. This prevents the framework from initializing rendering engines, database connections, etc to serve these types of requests.

It is common that PHP frameworks use a router to handle incoming HTTP requests. Web server forwards all requests to the PHP framework (often to the index.php file). This has the side-effect of static resources such as .jpg or .png requests being routed to the PHP framework as well.

Frameworks can generate a nice 404 Not Found error page, it is a waste of resources to generate nice error pages for images, videos, and other embeded content that are not the main URL the user accessed.

This package comes with configurable but sensible defaults, and when added as a middleware, it is executed early in the request, and short-circuits the rest of the bootstrap process and returns a quick and dirty "Not Found" page with the proper HTTP header. This can reduce the overhead by not having to connect to the database or fire up a rendering engine.

Note that the rest of the execution will be terminated with a PHP die() call. If you want to log the error messages via the framework events or other middleware, this package is not for you.

Installation

Usage

You need to execute the provided middleware within your framework. Here is an example for Slim v3:

1. Add Fast404Middleware class to the Container

2. Use the middleware in individual routes/groups, or for the whole application

Configuration

You can declare settings when the Fast404Middleware is instantiated:

Default match

By default, the following regular expression is used. It matches a list of pre-configured common extensions.

Configure it to your hearts desire; Just make sure that you absolutely don't want the framework to continue the requests for these types of extensions.

PSR-15 / PSR-7

As of now, there is a __invoke method that accepts PSR-7 ServerRequestInterface object. This makes this library immediately compatible with Slim v3. Proper PSR-15 support is in the works, and will be compatible with Slim v4 and any other compatible dispatcher.

Log 404 errors

This library immediately terminates the request with a configurable error message and an HTTP 404 error. There will be no logging. If you want your web server to log these same errors, it should not have handed over the request to the framework.

I really need 404 logging

No. Get out and implement this yourself. This is a 40 LOC package. This README is four times larger than the code.


All versions of fast404 with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
psr/http-message Version ^1.1 || ^2.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 phpwatch/fast404 contains the following files

Loading the files please wait ....