PHP code example of mezon / common-application

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

    

mezon / common-application example snippets


class           ExampleApplication extends CommonApplication
{
	/**
	 * Constructor.
	 */
	function			__construct( $template )
	{
		parent::__construct( $template );
	}

    function            actionSimplePage()
    {
        return [ 
            'title' => 'Route title' , 
            'main' => 'Route main'
        ];
    }
}

class           ExampleApplication extends CommonApplication
{
	/**
	 * Constructor.
	 */
	function			__construct($template)
	{
		parent::__construct($template);
	}

    function            actionSimplePage()
    {
        return [ 
            'title' => 'Route title' , 
            'main' => new View('Generated main content')
        ];
    }
}

class           ExampleApplication extends CommonApplication
{
	/**
	 * Constructor.
	 */
	function			__construct($template)
	{
		parent::__construct($template);

		// loading config on custom path
		$this->loadRoutesFromConfig('./my-routes.json');
	}

    function            route1()
    {
        return [ 
            // here result
        ];
    }

    function            route2()
    {
        return [ 
            // here result
        ];
    }
}

function			__construct($template)
	{
		parent::__construct($template);

		$this->loadRoutesFromConfigs(['./conf/my/routes.json', './conf/my-routes.php']);
	}

function			__construct($template)
	{
		parent::__construct($template);

		$this->loadRoutesFromDirectory('./conf');
	}