PHP code example of dmitrynaum / sam

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

    

dmitrynaum / sam example snippets



// Добавляем asset
Dmitrynaum\SAM\Asset::useCss('app.css');
// Выводим asset на страницу
echo Dmitrynaum\SAM\Asset::renderCss();


// Добавляем asset
Dmitrynaum\SAM\Asset::useJs('app.js');
// Выводим asset на страницу
echo Dmitrynaum\SAM\Asset::renderJs(['defer']);


// ...
Dmitrynaum\SAM\Asset::useJs('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js');
Dmitrynaum\SAM\Asset::useCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
// ...
echo Dmitrynaum\SAM\Asset::renderCss();
echo Dmitrynaum\SAM\Asset::renderJs();

Dmitrynaum\SAM\Asset::addInlineJs('alert("hello")');
Dmitrynaum\SAM\Asset::addInlineJs('alert("world")');
Dmitrynaum\SAM\Asset::addInlineCss('body{color:green;}');
Dmitrynaum\SAM\Asset::addInlineCss('h1{size:34px;}');

echo Dmitrynaum\SAM\Asset::renderInlineCss();
echo Dmitrynaum\SAM\Asset::renderInlineJs();

/**
* Результат работы
*
*<style>body{color:green;}
*h1{size:34px;}</style>
*
*<script>alert("hello");
*alert("world")</script>
*/



// ...
if (App::isDevelopment()) {
    Dmitrynaum\SAM\Asset::enableDevelopmentMode();
}
// ...

php vendor/bin/sam build

php vendor/bin/sam build -f

php vendor/bin/sam start-server