PHP code example of anahkiasen / flatten

1. Go to this page and download the library: Download anahkiasen/flatten library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anahkiasen / flatten example snippets


Flatten\FlattenServiceProvider::class,

'Flatten' => Flatten\Facades\Flatten::class,

// Manual flushing
Flatten::flushAll();
Flatten::flushPattern('users/.+');
Flatten::flushUrl('http://localhost/users/taylorotwell');

// Flushing via an UrlGenerator
Flatten::flushRoute('user', 'taylorotwell');
Flatten::flushAction('UsersController@user', 'taylorotwell');

// Flushing template sections (see below)
Flatten::flushSection('articles');

use Flatten\CacheHandler;

class UserObserver
{
    protected $cache;

    public function __construct(CacheHandler $cache)
    {
        $this->cache = $cache;
    }

    public function saved(User $user)
    {
        $this->cache->flushRoute('users.show', $user->id);
    }
}

<h1>This will always be dynamic</h1>
 foreach ($articles as $article): 

<!-- This section will be cached for 10 minutes -->
 Flatten::section('articles', 10, function () use ($articles) { 



Flatten\Flatten::kickstart();



$salt = mysql_query('SOMETHING');
Flatten\Flatten::kickstart($salt);


Flatten\Facades\Flatten;