PHP code example of nathanburkett / mesa

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

    

nathanburkett / mesa example snippets


 namespace Foo\Bar\Baz;

use NathanBurkett\Mesa\GeneratesTables;

class FooClass
{
    use GeneratesTables;
}

 namespace Foo\Bar\Baz;

use NathanBurkett\Mesa\GeneratesTables;

class FooClass
{
    use GeneratesTables;
    
    public function run(): iterable
    {
        $tableContext = __DIR__ . '/some/php/file.php';

        return $this->generateTable($tableContext);
    } 
}


// ./some/php/file.php

return [
    'one' => [
        'name' => 'foo',
    ],
    'two' => [
        'name' => 'bar',
    ],
];

 namespace Foo\Bar\Baz;

use NathanBurkett\Mesa\GeneratesTables;

class FooClass
{
    use GeneratesTables;
    
    public function run(): iterable
    {
        $tableContext = __DIR__ . '/some/php/file.php'; // THIS IS WHERE $tableContext COMES FROM

        return $this->generateTable($tableContext, function(array $row, $index) {
            if ($index === 'two') {
                $row['name'] = 'baz';
            }
            
            return $row;
        });
    } 
}

 namespace Foo\Bar\Baz;

use NathanBurkett\Mesa\GeneratesTables;
use NathanBurkett\Mesa\Loader\LoaderFactoryInterface;

class FooClass
{
    use GeneratesTables;
    
    // ...
    
    protected function getLoaderFactory(): LoaderFactoryInterface
    {
        return new YourNewFactoryLoader();
    }
}


// ./some/php/file.php

return [
    'one' => [
        'name' => 'foo',
    ],
    'two' => [
        'name' => 'bar',
    ],
];

 namespace Foo\Bar\Baz;

use NathanBurkett\Mesa\GeneratesTables;

class FooClass
{
    use GeneratesTables;
    
    public function run(): iterable
    {
        $tableContext = __DIR__ . '/some/php/file.php'; // THIS IS WHERE $tableContext COMES FROM

        return $this->generateTable($tableContext, function(array $row, $index) {
            if ($index === 'two') {
                $row['name'] = 'baz';
            }
            
            return $row;
        });
    } 
}