PHPackages                             geeks-dev/ngxcache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. geeks-dev/ngxcache

ActiveLibrary[Caching](/categories/caching)

geeks-dev/ngxcache
==================

4131PHP

Since Sep 25Pushed 11y ago3 watchersCompare

[ Source](https://github.com/geeks-dev/ngxcache)[ Packagist](https://packagist.org/packages/geeks-dev/ngxcache)[ RSS](/packages/geeks-dev-ngxcache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Nginx Cache Controller for Laravel 4
====================================

[](#nginx-cache-controller-for-laravel-4)

[日本語ドキュメントはコチラ](http://www.geeks-dev.com/laravel%E3%81%A7nginx%E3%81%AE%E3%82%AD%E3%83%A3%E3%83%83%E3%82%B7%E3%83%A5%E3%82%92%E5%88%B6%E5%BE%A1%E3%81%99%E3%82%8Bngxcache/)

Installation
------------

[](#installation)

Add `geeks-dev/ngxcache` as a requirement to composer.json.

```
{
	"require": {
		"geeks-dev/ngxcache": "dev-master"
	}
}

```

Update your packages with composer update or install with composer install.

Once Ngxcache is installed you need to register the service provider with the application. Open up `app/config/app.php` and find the `providers` key.

```
'providers' => array(

	'Geeksdev\Ngxcache\NgxcacheServiceProvider'

)

```

Ngxcache also ships with a facade which provides the static syntax for creating collections. You can register the facade in the `aliases` key of your `app/config/app.php` file.

```
'aliases' => array(

	'Ngxcache' => 'Geeksdev\Ngxcache\Facades\Ngxcache'

)

```

### Configure Nginx server

[](#configure-nginx-server)

Add `fastcgi_pass_header` (`X-Accel-Redirect`,`X-Accel-Buffering`,`X-Accel-Charset`,`X-Accel-Expires`,`X-Accel-Limit-Rate`) .

```
location ~ \.php$ {
	fastcgi_split_path_info ^(.+\.php)(/.+)$;
	fastcgi_index index.php;

	fastcgi_pass_header "X-Accel-Redirect";
	fastcgi_pass_header "X-Accel-Buffering";
	fastcgi_pass_header "X-Accel-Charset";
	fastcgi_pass_header "X-Accel-Expires";
	fastcgi_pass_header "X-Accel-Limit-Rate";

	fastcgi_cache_key       $scheme://$host$request_uri;
						.
						.
						.

```

### Congirure Package

[](#congirure-package)

Run this command.

```
php artisan config:publish geeks-dev/ngxcache

```

See the configuration file of your Nginx. ```
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=cache:4m inactive=7d max_size=50m;

```

Edit `app/config/packages/geeks-dev/ngxcache/config.php` Please specify the directory where the cache of the proxy or FastCGI is stored ```
/*
|--------------------------------------------------------------------------
| Nginx Cache Location
|--------------------------------------------------------------------------

'nginx_cache_path' => '/var/run/nginx-cache',

/*
|--------------------------------------------------------------------------
| Nginx Cache Levels
|--------------------------------------------------------------------------
*/

'nginx_levels' => '1:2',

```

Ngixcache Commands
------------------

[](#ngixcache-commands)

```
ngxcache:backtrace          Nginx display URL by tracing back all caches.  '', 'before' => 'nginx.cache-enable'), function(){
	Route::get('/', 'HomeController@getIndex');
	Route::get('{id}/show', 'HomeController@getShow');
});

Route::group(array('prefix' => '', 'before' => 'nginx.cache-disable'),function(){

	Route::post('auth/login', 'AuthController@postIndex');
	Route::controller('auth', 'AuthController');
});

```

Ngixcache Methods
-----------------

[](#ngixcache-methods)

```
/**
 * Search nginx cache of all.
 * example:[$result = Ngxcache::items();]
 *
 * @return result
 */
Ngxcache::items();

/**
 * Purge nginx cache of all.
 * example:[Ngxcache::purgeall();]
 *
 * @return result
 */
Ngxcache::purgeall();

/**
 * Purge or search Nginx cache.
 * example:[Ngxcache::purge($uri);]
 *
 * @param  string  $uri
 * @param  bool    $searchmode
 * @return result
 */
Ngxcache::purge($uri,$searchmode=false)
(It does not purge is performed only search Search Mode)

/**
 * Rebuild Nginx cache.
 * example:[Ngxcache::rebuild($uri,true,false);]
 *
 * @param  string  $uri
 * @param  bool    $overwrite
 * @param  bool    $usecurl
 * @param  bool    $cached_only
 * @return result
 */
Ngxcache::rebuild($uri,$overwrite=false,$usecurl=false,$cached_only=false)
(Second argument will do the forcibly overwritten.
 　　Only if the cache does not exist , the cache is created normally.
 	Third argument is curl or file_get_contents)

/**
 * Backtrace uri from Nginx cache.
 * example:[Ngxcache::rebuild($cachePath);]
 *
 * @param  string  $cachePath
 * @return string  $uri
 */
Ngxcache::backtrace($cachePath);

```

Trouble shooting
----------------

[](#trouble-shooting)

### open\_basedir restriction in effect.

[](#open_basedir-restriction-in-effect)

Add the cache directory of Nginx to `open_basedir` in the `php.ini` If the operation of the cache does not work if.

```
(Example)
open_basedir = .:/usr/share/php:/usr/share/pear:/var/run/nginx-cache

```

### If the cache does not match at Homestead environment

[](#if-the-cache-does-not-match-at-homestead-environment)

Measures There are two .

#### Pattern A

[](#pattern-a)

Run `vagrant ssh` after `sudo vim /etc/nginx/sites-available/homestead.app`

```
server {
-	listen 80;
+	listen 8000;

```

After run `exit` command.

Next step =&gt; edit `scripts/homestead.rb`

```
# Configure Port Forwarding To The Box
- config.vm.network "forwarded_port", guest: 80, host: 8000
+ config.vm.network "forwarded_port", guest: 8000, host: 8000

```

Please try to run the `vagrant reload` when finished.

#### Pattern B

[](#pattern-b)

Run `vagrant ssh` after `sudo vim /etc/nginx/sites-available/homestead.app`

```
server {
	listen 80;
+	listen 8000;

```

Please try to run the `sudo service nginx reload` when finished.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dd703625b9219a488f367ecdfa6b7736f93d8ef1a1a93f8d3d0ab5d8b380d15?d=identicon)[geeks-dev](/maintainers/geeks-dev)

### Embed Badge

![Health badge](/badges/geeks-dev-ngxcache/health.svg)

```
[![Health](https://phpackages.com/badges/geeks-dev-ngxcache/health.svg)](https://phpackages.com/packages/geeks-dev-ngxcache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
