glavweb/silex-static-page-generator

此包最新版本(0.1.1)没有可用的许可信息。

Silex 静态页面生成器包

0.1.1 2017-02-26 06:09 UTC

This package is auto-updated.

Last update: 2024-09-24 03:08:10 UTC


README

使用 composer 获取包

在 Silex 项目的根目录下通过终端运行此命令以添加 SilexStaticPageGenerator

php composer.phar require glavweb/silex-static-page-generator

在控制台文件中注册命令

#!/usr/bin/env php
<?php

set_time_limit(0);

require __DIR__ . '/../vendor/autoload.php';

use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
use Glavweb\SilexStaticPageGenerator\Command\GenerateStaticPagesCommand;

$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], 'dev');
$debug = !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';

if ($debug) {
    Debug::enable();
}

$app = new Application();
$app->prepare('prod');

$console = new ConsoleApplication();

// ... register commands

$baseUrl = ''; // define the project URL in your the config file
$webDir  = realpath(__DIR__ . '/../web');

$console->add(new GenerateStaticPagesCommand(
    $app['routes'],
    $app['controllers'],
    $app['url_generator'],
    $baseUrl,           // Base URL, as example: http://my_project.com
    $webDir . '/static' // The place where will generate static pages
));

$console->run($input);

注意:您需要定义 "$baseUrl" 和 "$webDir"。

用法

运行命令 "generate:static-pages"

php bin/console generate:static-pages

将在控制台文件中定义的文件夹($webDir . '/static')中生成页面。