Download the PHP package deltablue/laravel-varnish without Composer

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

Making Varnish and Laravel play nice together

Latest Version on Packagist Build Status Quality Score Total Downloads

This package provides an easy way to work with Varnish 4 (or 5) in Laravel. It provides a route middleware that, when applied to a route, will make sure Varnish will cache the response no matter what. The package also contains a function to flush the Varnish cache from within the application.

Installation

We assume that you've already installed Varnish on your server. If not read this blogpost to learn how to install it.

You can install the package via composer:

The package will automatically register itself for Laravel 5.5+.

If you are using Laravel < 5.5, you also need to add Varnish\VarnishServiceProvider to your config/app.php providers array:

Next if you use Laravel you must publish the config-file with:

and if you use Lumen, you must copy config/varnish.php file to your application config folder.

This is the contents of the published file:

In the published varnish.php config file you should set the host key to the right value. Also make sure that the execution_type is set to socket if you would like to use this command to flush the cache of a remote Varnish server. Set execution_type to command to use varnishadm on the local system.

In case you've set the execution_type to socket, you can either store the administrative secret in a file and set administrative_secret, as used by varnishadm, or provide the actual secret string in the administrative_secret_string variable.

Add the DeltaBlue\Varnish\Middleware\CacheWithVarnish middleware to the route middlewares.

For Laravel:

If you are using Lumen, you need to load config file before route middleware definition to your bootstrap/app.php:

Finally, you should add these lines to the vcl_backend_response function in your VCL (by default this is located at /etc/varnish/default.vcl on your server):

We highly recommend using the VCL provided the varnish-5.0-configuration-templates repo made by Mattias Geniar.

Usage

Caching responses

The routes whose response should be cached should use the cacheable middleware.

The amount of minutes that Varnish should cache this content can be configured in the cache_time_in_minutes key in the laravel-varnish.php config file. Alternatively you could also use a middleware parameter to specify that value.

Behind the scenes the middleware will add an X-Cacheable and Cache-Control to the response. Varnish will remove all cookies from Laravel's response. So keep in mind that, because thelaravel_session cookie will be removed as well, sessions will not work on routes were the CacheWithVarnish middleware is applied.

Clearing cache from Varnish

There's an artisan command to flush the cache. This can come in handy in your deployment script.

If execution_type is set to command, under the hood flushing the cache will call the sudo varnishadm. To make it work without any hassle make sure the command is run by a unix user that has sudo rights.

You can also do this in your code to flush the cache:

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONTRIBUTING for details.

Credits

License

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


All versions of laravel-varnish with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0
illuminate/console Version ~5.5.0|~5.6.0|~5.7.0
illuminate/http Version ~5.5.0|~5.6.0|~5.7.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 deltablue/laravel-varnish contains the following files

Loading the files please wait ....