PHP code example of webiny / bootstrap

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

    

webiny / bootstrap example snippets




namespace MySuperApp\Modules\MySuperAwesomeModule\Controllers;

class Homepage
{
    use Webiny\Component\Bootstrap\ApplicationTraits\AppTrait;

    public function doSomethingAction()
    {
        // your code goes here
    }
}

class Homepage
{
    use Webiny\Component\Bootstrap\ApplicationTraits\AppTrait;

    public function doSomethingAction()
    {
        // get absolute path
        $this->app()->getAbsolutePath();
        
        // get web path
        $this->app()->getWebPath();
    
        // assign data to the view
        $viewData = [
            'title' => 'This is a title'
        ];
        $this->app()->view()->assign($viewData);
    }
}

class Homepage
{
    use Webiny\Component\Bootstrap\ApplicationTraits\AppTrait;

    public function doSomethingAction()
    {
        $this->app()->view()
             ->setTitle('Webiny Todo App')
             ->setMeta('description', 'Webiny demo Todo application')
             ->appendStyleSheet('//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css')
             ->appendScript('//code.jquery.com/jquery-2.1.1.min.js')
             ->appendScript('//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js');
    }
}

class Homepage
{
    use Webiny\Component\Bootstrap\ApplicationTraits\AppTrait;

    public function doSomethingAction()
    {
        // outputs 'Webiny Todo App'
        $this->app()->view()->getTitle();
        
        // outputs '<title>Webiny Todo App</title>' 
        $this->app()->view()->getTitleHtml();
        
        // outputs an array of scripts
        $this->app()->view()->getScripts();
        
        // outputs a list of scripts as a HTML tags
        $this->app()->view()->getScriptsHtml();
        
        //...and few other, checkout the View.php class inside the ApplicationClasses folder
    }
}

public function sayHiAction($name, $location='Planet Earth')
{
    echo 'Hi '.$name.', from '.$location;    
}

Modules/
    |- MySuperAwesomeModule/
        |- Controllers/
            |- Homepage.php
            |- ProductSearch.php
        |- Views/
            |- Homepage/
                |- DoSomething.tpl