I've currently got laravel illuminate database and eloquent working outside of laravel.
I'm now trying to get the cache working as well.
This is what I have altogether now.
<?php
require dirname(dirname(__DIR__)) . '/vendor/autoload.php';
require dirname(__DIR__) . '/config.php';
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Cache\CacheManager as CacheManager;
$dbc = new DB;
$dbc->addConnection(array(
'driver' => 'mysql',
'host' => DB_HOST,
'database' => DB_NAME,
'username' => DB_USER,
'password' => DB_PASSWORD,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
));
# Set the default fetch mode for all queries
$dbc->setFetchMode(PDO::FETCH_CLASS);
# Set up the cache
$container = $dbc->getContainer();
$container['config']['cache.driver'] = 'memcached';
$container['config']['cache.memcached'] = array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100);
$container->offsetGet('config')->offsetSet('cache.driver', 'array');
$cacheManager = new CacheManager($container);
$dbc->setCacheManager($cacheManager);
$dbc->setAsGlobal();
$dbc->bootEloquent();
global $dbc;
This is not working for me, despite having memcached and php module memcached installed and working.
UPDATE I get no errors with this configuration. I am just not seeing anything coming into memcached. I've tested with the following line of code.
$dbc->table('users')->limit(10)->cacheTags(array('people', 'authors'))->remember(10)->get();
Whilst watching on the box with
[root@localhost vagrant]# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats items
END