Download the PHP package linslin/laravel-coffee-cache without Composer

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

☕ laravel-coffee-cache

Total Downloads License

Store based lever out view cache for Laravel 4.x, 5.x 6.x, 7.x, 8.x, 9.x, 10.x and 11.x. This cache hook in before composer autoload and Laravel bootstrapping. It will push your application into light speed. By default, all GET-Requests will be cached.

It's a coffee cache. You can drink more coffee instead of spending time to optimize your application or server environment. Mokka Mokka!

Why and when should I use laravel-coffee-cache?

Laravel getting bigger and bigger over the years. Today laravel is a very nice framework which helps you to speed up your software development and programming in its best way. On the other hand laravel is slow in handling requests and consumes a lot of memory per request, even if you use View or Database caches. The bootstrapping of laravel takes a bit time also it consumes a lot of memory. E.g. if you want to render an "imprint / disclaimer" page which doesn't have any dynamic data in its view. So, why you want to bootstrap laravel and all its dependencies just for returning a simple HTML page?

laravel-coffee-cache allows you to lever out laravel and composer autoload completely once a cache file has been generated for a specific route (Request URI). In this way it consumes so much less hardware resources (CPU, RAM, Hard Disk) for each request. It will be push your application into light speed.

The difference to existing cache systems for laravel is: You don't need to have a DB cache based on memcached or even a view file based cache placed in a laravel middleware. Hint: It's nice approach is to combine your DB Cache with laravel-coffee-cache. Use your DB Cache even if you have laravel-coffee-cache running in the foreground.

You will be able to create highly frequented web applications and save a lot of hardware resources (which also saves money) with ☕ laravel-coffee-cache. It makes to optimize your applications if your website is too slow or your server / server capacities (CPU, Memory) run at full load. Give it a try.

Installation

composer require --prefer-dist linslin/laravel-coffee-cache "*"

Register Facade

If you want to use the facade to handle the cache files, add this to your facades in config/app.php in the alias array:

'CoffeeCache' => linslin\CoffeeCache\Facades\CoffeeCache::class,

Example ./config/coffeeCache.php config file

return [

    /**
     * Cache driver: 'file' or 'redis'
     */
    'driver' => 'file',

    /*
     * Redis connection
     */
    'redis' => [
        'host' => 'localhost',
        'port' => 6000,
        'password' => '', //leave empty if no password is given
        'timeout' => 0.5
    ],
];

API Documentation

Initialize instance

Should be placed in your app/public/index.php file.

$coffeeCache = new CoffeeCache(__DIR__);

Configure enabled hosts for caching [optional]

Matching hosts which should be cached. Default: Cache all domains

$coffeeCache->enabledHosts = [
    'www.production.com',
    'subdomain.production.com',
]; 

Configure enabled hosts with sessions for caching [optional]

Matching hosts which should be cached only if a cookie cached=1 is set. Default: Cache all domains

$coffeeCache->enabledCacheHostsWithSession = [
    'www.production.com',
    'subdomain.production.com',
]; 

Configure query parameters to exclude from request uri [optional]

Matching query parameters are excluded from the request uri. A request uri with an excluded query param is treated like if the parameter is not set. Default: no query parameter is exclude

$coffeeCache->excludeQueryParam  = [
    'aQueryParameter',
]; 

Enable / disable the whole cache [optional|default:true]

Flag for easy disabling the cache.

$coffeeCache->cacheEnabled = true;   

Configure the cache driver (file, redis) [optional|default:'file'|'redis']

$coffeeCache->cacheDriver = 'redis';
$coffeeCache->redisConnection = [
    'host' => 'localhost',
    'port' => 6000,
    'password' => '',
    'timeout' => 0.5
];

Configure HTTP-Status codes which should be cached [optional]

List of HTTP-Status codes which should be cached. Default: Cache "200" only.

$coffeeCache->enabledHttpStatusCodes = [
  '200',
  '202',
]; 

Exclude URL patterns from being cached. [optional]

URL patterns of URLs which should not be cache. This example will exclude URLS which have "/admin" somewhere in the URL.

$coffeeCache->excludeUrls = [
    '/admin',
]; 

Enable minify cache data [optional]

Strip whitespaces after tags, except space. Strip whitespaces before tags, except space. Shorten multiple whitespace sequences. Remove HTML comments

$coffeeCache->minifyCacheFile = true;

Enable cookie handled cache [optional]

The cache only will work if a cookie named "cached" is available and hold the value "1". This is for handling user sessions while running coffeeCache. It allows you to enable / disable cache for logged in users. Create a cookie with cached=1 if a user is not logged in. Create a cookie with cached=0 if a user is logged in.

$coffeeCache->cookieHandledCacheEnabled = true;

Enable compression [optional]

Enable gzip compression for cache data. Default is false.

$coffeeCache->gzipEnabled = true;

Filter content types from being minified. [optional]

Response content types which will be ignored and not minified.

$coffeeCache->minifyIgnoreContentTypes = [
    'image/png',
    'image/gif',
    'image/jpg',
    'image/jpeg',
];

Global replacements [optional]

Will replace some string marker in our cached file. Which allows you to globally manipulate the cache data. You can parse a string or filepath. The file contents will replace the marker string.

$coffeeCache->globalReplacements = [
    [
        'type' => 'string',
        'marker' => '###marker1####',
        'value' => 'hallo welt'
    ], [
        'type' => 'file',
        'marker' => '###marker2####',
        'filePath' => __DIR__.'/../public/test.txt'
    ], [
        'type' => 'file',
        'marker' => '###start_marker####',
        'markerEnd' => '###end_marker####',
        'filePath' => __DIR__.'/../public/test.txt'
    ]
];

Facade API Documentation

Delete all cache files

CoffeeCache::clearCache();

Manually delete cache files

CoffeeCache::clearCacheFile(route('route.name', [], false));

Check if cache file exist

CoffeeCache::cacheFileExists(route('route.name', [], false));

Get creation date (file driver only)

CoffeeCache::getCacheFileCreatedDate(route('route.name', [], false));

Example: Manually delete cache a specific file

E.g. inside a controller - example:

<?php

namespace App\Http\Controllers\Admin\Shop;

use App\Models\Shop;
use Illuminate\Http\Request;
use linslin\CoffeeCache\Facades\CoffeeCache;

/**
 * Class EntryController
 * @package App\Http\Controllers\Admin
 */
class EntryController extends ShopBaseController
{

    /**
     * @param Request $request
     * @param Shop $shop
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function update(Request $request, Shop $shop)
    {
        //manually delete cache file for a route (if exists)
        CoffeeCache::clearCacheFile(route('shop.show', ['shop' => $shop->slug], false));

        return view('admin.shop.form',[
            'shop' => $shop,
        ]);
    }
}

Setup and usage

Changelog

1.25.0

1.24.3

1.24.2

1.24.1

1.24.0

1.23.1

1.23.0

1.22.2

1.22.1

1.22.0

1.21.2

1.21.1

1.21.0

1.20.0

1.19.0

1.18.0

1.17.0

1.16.0

1.15.3

1.15.2

1.15.1

1.15.0

1.14.0

1.13.1

1.13.0

1.12.2

1.12.1

1.12.0

1.11.1

1.11.0

1.10.0

1.9.0

1.8.3

1.8.2

1.8.1

1.8.0

1.7.2

1.7.1

1.7.0

1.6.0

1.5.0

1.4.0

1.3.0

1.2.0

1.1.0

1.0.0

Credits

Thanks to robre21 and delacruzsippel!


All versions of laravel-coffee-cache with dependencies

PHP Build Version
Package Version
Requires ext-mbstring Version *
ext-zlib Version *
mobiledetect/mobiledetectlib Version ^2.8
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 linslin/laravel-coffee-cache contains the following files

Loading the files please wait ....