PHP code example of bear / app-meta

1. Go to this page and download the library: Download bear/app-meta 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/ */

    

bear / app-meta example snippets


use BEAR\AppMeta\Meta;

// Initialize with your application's namespace
$appMeta = new Meta('MyVendor\HelloWorld');

// Access metadata properties
echo $appMeta->name;    // MyVendor\HelloWorld
echo $appMeta->appDir;  // /path/to/MyVendor/HelloWorld/src
echo $appMeta->logDir;  // /path/to/MyVendor/HelloWorld/var/log
echo $appMeta->tmpDir;  // /path/to/MyVendor/HelloWorld/var/tmp

// Fetch metadata for all resources
foreach ($appMeta->getGenerator('*') as $resourceMeta) {
    var_dump($resourceMeta->uriPath); // app://self/one
    var_dump($resourceMeta->class);   // FakeVendor\HelloWorld\Resource\App\One
    var_dump($resourceMeta->file);    // /path/to/src/Resource/App/One.php
}

// Fetch metadata for resources in the 'app' namespace
foreach ($appMeta->getGenerator('app') as $resourceMeta) {
    var_dump($resourceMeta->uriPath); // /one
    var_dump($resourceMeta->class);   // FakeVendor\HelloWorld\Resource\App\One
    var_dump($resourceMeta->file);    // /path/to/src/Resource/App/One.php
}