PHP code example of petrknap / nette-bootstrap

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

    

petrknap / nette-bootstrap example snippets


Bootstrap::getContainer()->getByType("Nette\\Application\\Application")->run();



class Bootstrap extends \PetrKnap\Nette\Bootstrap\Bootstrap
{
    protected function getConfigFiles()
    {
        return array(
            __DIR__ . "/cfg/config.neon",
            self::getOption(self::OPTION_IS_TEST_RUN) ? __DIR__ . "/cfg/test.neon" : __DIR__ . "/cfg/local.neon"
        );
    }
}



class NetteTestCase extends \PetrKnap\Nette\Bootstrap\PhpUnit\NetteTestCase
{
    const NETTE_BOOTSTRAP_CLASS = "Bootstrap";
}



class NetteTestCase extends \PetrKnap\Nette\Bootstrap\PhpUnit\NetteTestCase
{
    public function testHelloWorld()
    {
        /** @var \Nette\Application\Responses\TextResponse $response */
        $response = $this->runPresenter("World", "hello"); // calls WorldPresenter::actionHello
        $html = (string) $response->getSource(); // renders output
        $this->assertContains("Hello, world!", $html);
    }
}
xml
<phpunit>
    <php>
      <const name="NETTE_BOOTSTRAP_CLASS" value="Bootstrap"/>
    </php>
</phpunit>