Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Files ModelsMetadata not working

I'm trying to implement models metadata. It's working in memory \Phalcon\Mvc\Model\Metadata\Memory() but it's not working with \Phalcon\Mvc\Model\Metadata\Files( ).

The metaDataDir is writable (777) but no files are being written.

    $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Files([
                    'metaDataDir' => APPLICATION_PATH . "/cache/Metadata/",
                ]);
    $di->setShared('modelsMetadata', $modelsMetadata)

Models cahce is working properly.

    $frontCache = new \Phalcon\Cache\Frontend\Data([
        "lifetime" => $config->metadata->lifetime * 30
    ]);

    $modelsCache = new \Phalcon\Cache\Backend\File(
        $frontCache,
        [
            "cacheDir" => APPLICATION_PATH . "/cache/Data/",
            "prefix"   => $config->metadata->prefix
        ]
    );
    $di->setShared('modelsCache', $modelsCache);

And models manager is also declared.

    $modelsManager = new \Phalcon\Mvc\Model\Manager();

    $di->setShared('modelsManager', $modelsManager);
$di->setShared('modelsMetadata', function () use ($config) {
    return new \Phalcon\Mvc\Model\MetaData\Files(array(
        'metaDataDir' => $config->application->cacheDir . 'metaData/',
        "lifetime" => 86400,
        "prefix" => "tMeta"
    ));
});
edited Jan '16

Still not working...

$di->setShared('modelsMetadata', function () use ($config) {
    return new \Phalcon\Mvc\Model\MetaData\Files(array(
        'metaDataDir' => $config->application->cacheDir . 'metaData/',
        "lifetime" => 86400,
        "prefix" => "tMeta"
    ));
});


737

A had the same issue. Look at your

$modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Files([ ...

there is a typing error in "Metadata". Use "MetaData"



9.3k
Accepted
answer

I forgot to put the answer.

Just start Cache service BEFORE Database service.