1. Go to this page and download the library: Download forrest79/deploy-php 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/ */
forrest79 / deploy-php example snippets
use Forrest79\DeployPhp;
sets(
__DIR__ . '/../temp',
__DIR__ . '/assets',
[
'images' => DeployPhp\Assets::COPY,
'fonts' => DeployPhp\Assets::COPY,
'css/styles.css' => [ // target file
'type' => DeployPhp\Assets::LESS,
'file' => 'css/main.less',
],
'css/styles' => [ // target directory, main.css will be created here
'type' => DeployPhp\Assets::SASS,
'file' => 'css/main.sass',
],
'css/many-styles' => [ // target directory, main.css and print.css will be created here
'type' => DeployPhp\Assets::SASS,
'files' => [
'css/main.sass',
'css/print.sass',
]
],
'js/scripts.js' => [ // target file
'type' => DeployPhp\Assets::JS,
'files' => [
'js/bootstrap.js',
'js/modernizr-custom.js',
'js/web.js',
],
],
'js/jquery.min.js' => DeployPhp\Assets::COPY,
'js/jquery.min.map' => [
'type' => DeployPhp\Assets::COPY,
'env' => DeployPhp\Assets::DEBUG,
],
'js/scripts.{format}.js' => [ // target file - will be compiled for more formats
'type' => DeployPhp\Assets::ROLLUP,
'file' => 'js/index.js',
],
],
static function (string $configFile): ?string {
if (!file_exists($configFile)) {
return NULL;
}
$data = Neon\Neon::decode(file_get_contents($configFile));
if (!isset($data['assets']['hash'])) {
return NULL;
}
return $data['assets']['hash'];
},
static function (string $configFile, string $hash): void {
file_put_contents($configFile, "assets:\n\t\thash: $hash\n");
},
((($localConfig = @
$configurator->addConfig(__DIR__ . '/config/config.neon');
if (PHP_SAPI !== 'cli') {
$assetsConfigFile = __DIR__ . '/config/config.assets.neon';
$configurator->addConfig($assetsConfigFile);
if ($configurator->isDebugMode()) {
$assets = @
// Service to use in application
namespace App\Assets;
class Assets
{
/** @var string */
private $hash;
public function __construct(string $hash)
{
$this->hash = $hash;
}
public function getHash(): string
{
return $this->hash;
}
}
// Extension that uses neon structure with hash (just register this as extension in config.neon)
namespace App\Assets\DI;
use App\Assets;
use Nette\DI\CompilerExtension;
class Extension extends CompilerExtension
{
private $defaults = [
'hash' => NULL,
];
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->validateConfig($this->defaults, $this->config);
$builder->addDefinition($this->prefix('assets'))
->setFactory(Assets\Assets::class, [$config['hash']]);
}
}