staticka/console
Composer 安装命令:
composer require staticka/console
包简介
Terminal-based package for Staticka.
README 文档
README
Console is a terminal-based package of Staticka which allows creating and building of pages through a terminal.
Installation
Install the Console package via Composer:
$ composer require staticka/console
Basic usage
To create a new page, use the create command with its title:
$ vendor/bin/staticka create "Hello world!" [PASS] "Hello world!" page successfully created!
<!-- pages/20241028202552_hello-world.md --> --- name: Hello world! link: /hello-world title: Hello world! description: tags: category: --- # Hello world!
ciacme/
├── pages/
│ └── 20241028202552_hello-world.md
├── vendor/
└── composer.json
After adding some text to the newly created page, use the build command to compile the .md files to .html:
$ vendor/bin/staticka build
[PASS] Pages successfully compiled!
ciacme/
├── build/
│ └── hello-world/
│ └── index.html
├── pages/
│ └── 20241028202552_hello-world.md
├── vendor/
└── composer.json
<!-- build/hello-world/index.html --> <h1>Hello world!</h1>
Note
Console will try to create the required directories (e.g., build, pages) if they do not exists in the current working directory.
Using staticka.yml
Console typically works out of the box without any configuration. But if there is a need to change the path of its other supported directories or needs to extend the core functionalities of Console, the staticka.yml file can be used in those kind of scenarios:
# staticka.yml root_path: %%CURRENT_DIRECTORY%% timezone: Asia/Manila assets_path: %%CURRENT_DIRECTORY%%/assets build_path: %%CURRENT_DIRECTORY%%/build config_path: %%CURRENT_DIRECTORY%%/config pages_path: %%CURRENT_DIRECTORY%%/pages plates_path: %%CURRENT_DIRECTORY%%/plates scripts_path: %%CURRENT_DIRECTORY%%/scripts styles_path: %%CURRENT_DIRECTORY%%/styles
To create the said staticka.yml file, simply run the initialize command:
$ vendor/bin/staticka initialize [PASS] "staticka.yml" added successfully!
After successfully creating the said file, it will provide the following properties below:
root_path
This property specifies the current working directory. By default, it uses the %%CURRENT_DIRECTORY%% placeholder that returns the current directory of the staticka.yml file:
# staticka.yml root_path: %%CURRENT_DIRECTORY%%/Sample # ...
timezone
This allows to change the timezone to be used when creating timestamps of a new page. If not specified, Console will use the default timezone specified in the php.ini file:
# staticka.yml timezone: Asia/Tokyo # ...
assets_path
This specifies the path for all other web assets like images (.jpg, .png) and PDF files (.pdf). Console does not use this specified path but it might be useful to locate the directory for organizing asset files:
# staticka.yml assets_path: %%CURRENT_DIRECTORY%%/assets # ...
build_path
This is the property that will be used by Console to determine the destination directory of the compiled pages:
# staticka.yml build_path: %%CURRENT_DIRECTORY%%/build # ...
config_path
One of the properties of Console that locates the directory for storing configuration files. If defined, it will load its .php files to a Configuration class. The said class is useful when creating extensions to Console:
# staticka.yml config_path: %%CURRENT_DIRECTORY%%/config # ...
// config/parser.php return array( /** * @var \Staticka\Filter\FilterInterface[] */ 'filters' => array( 'Staticka\Expresso\Filters\GithubFilter', 'Staticka\Expresso\Filters\ReadmeFilter', ), );
// src/Package.php namespace Ciacme; use Rougin\Slytherin\Container\ContainerInterface; use Rougin\Slytherin\Container\ReflectionContainer; use Rougin\Slytherin\Integration\Configuration; use Rougin\Slytherin\Integration\IntegrationInterface; class Package implements IntegrationInterface { public function define(ContainerInterface $container, Configuration $config) { // Will try to access the "config/parser.php" file --- /** @var class-string[] */ $filters = $config->get('parser.filters', array()); // --------------------------------------------------- // ... } }
Note
To allow custom packages for Console, kindly add the specified package class in staticka.yml. Please see the Extending Console section below for more information.
pages_path
This is the location of the generated pages from create command:
# staticka.yml pages_path: %%CURRENT_DIRECTORY%%/pages # ...
plates_path
One of the special variables of Console to specify a directory that can be used for third-party templating engines (RenderInterface):
# staticka.yml plates_path: %%CURRENT_DIRECTORY%%/plates # ...
scripts_path
This is the property for the directory path of script files (.js, .ts). Although not being used internally by Console, this property can be used when extending core functionalities (e.g., compiling .js files through Webpack when running the build command):
# staticka.yml scripts_path: %%CURRENT_DIRECTORY%%/scripts # ...
styles_path
Same as scripts_path, this property specifies the directory path for styling files (.css, .sass):
# staticka.yml styles_path: %%CURRENT_DIRECTORY%%/styles # ...
Extending Console
Console is based on the Slytherin PHP micro-framework which provides an easy way to integrate custom packages through IntegrationInterface. The said interface can be used to create instances related to Staticka:
// src/Package.php namespace Ciacme; use Rougin\Slytherin\Container\ContainerInterface; use Rougin\Slytherin\Container\ReflectionContainer; use Rougin\Slytherin\Integration\Configuration; use Rougin\Slytherin\Integration\IntegrationInterface; use Staticka\Filter\HtmlMinifier; use Staticka\Layout; class Package implements IntegrationInterface { /** * This sample package will always minify the compiled HTML files. * * @param \Rougin\Slytherin\Container\ContainerInterface $container * @param \Rougin\Slytherin\Integration\Configuration $config * * @return \Rougin\Slytherin\Container\ContainerInterface */ public function define(ContainerInterface $container, Configuration $config) { $layout = new Layout; $layout->addFilter(new HtmlMinifier); $container->set(get_class($layout), $layout); return $container; } }
To add the specified custom package, kindly add it to the staticka.yml file:
# staticka.yml root_path: %%CURRENT_DIRECTORY%% # ... packages: - Ciacme\Package
Changelog
Please see CHANGELOG for more recent changes and latest updates.
Contributing
See CONTRIBUTING on how to contribute to the project.
License
The MIT License (MIT). Please see LICENSE for more information.
staticka/console 适用场景与选型建议
staticka/console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 179 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php-console」 「site-generator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 staticka/console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 staticka/console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 staticka/console 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel service provider to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
Silex service provider to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
A bootstrap for PHP console projects.
Yet another PHP static site generator.
A powerful command line interface (CLI) for PHP projects, built on top of adhocore/cli.
A WordPress implementation of PHP Console.
统计信息
- 总下载量: 179
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-04-04