命令行界面
October包括几个命令行界面(CLI)命令和实用程序,允许安装October,更新它,以及加快开发过程。 控制台命令基于Laravel的Artisan 工具。 您可以开发自己的控制台命令或使用提供的脚手架命令加速开发。
控制台安装
可以使用本机系统或Composer 来执行控制台安装,以管理依赖项。 这两种方法都会下载October的应用程序文件,可以立即使用。 如果您打算使用数据库,请确保在安装后运行安装命令行。
快速安装
在您的终端中运行此命令以获取October的最新的代码:
curl -s https://octobercms.com/api/installer | php
如果你没有curl,可以执行以下命令:
php -r "eval('?>'.file_get_contents('https://octobercms.com/api/installer'));"
Composer安装
在终端中使用create-project
下载应用程序源代码。 以下命令将安装到名为 /myoctober 的目录中。
composer create-project october/october myoctober
完成此任务后,打开文件 config/cms.php 并启用disableCoreUpdates
设置。 这将禁用October提供的核心更新。
'disableCoreUpdates' => true,
如果您正在开发一个站点并希望在更新时获得October的最新和最大的更改,那么更新composer.json
文件以使用以下内容; 这使您可以测试开发分支的最新改进。
"october/rain": "dev-develop as 1.0",
"october/system": "dev-develop",
"october/backend": "dev-develop",
"october/cms": "dev-develop",
"laravel/framework": "5.5.*@dev",
更新October时,在执行数据库迁移之前,正常使用composer update命令。
composer update
Composer被配置为查看插件目录内部的composer依赖,这些将包含在更新中。
注意: 要将composer与使用安装向导安装的October实例一起使用,只需复制
tests/
目录,composer.json
文件和server.php
从GitHub 文件到你的October实例,然后运行composer install
。
设置和维护
安装命令
october:install
命令将指导您完成首次设置OctoberCMS的过程。 它将询问数据库配置,应用程序URL,加密密钥和管理员详细信息。
php artisan october:install
您还可以检查config/app.php和config/cms.php以更改其他的配置。
注意: 运行
october:env
后无法运行october:install
。october:env
获取现有的配置值,并将它们放在.env
文件中,同时在配置文件中调用env()
替换原始值。october:install
现在无法在配置文件中替换对env()
的调用,因为管理过于复杂。
系统更新
october:update
命令将从October网站api请求更新。 它将更新核心应用程序和插件文件,然后执行数据库迁移。
php artisan october:update
注意: 如果使用composer安装,则不会下载核心应用程序文件,并且在运行此命令之前应调用
composer update
。
数据库迁移
october:up
命令将执行数据库迁移,创建数据库表并执行由系统提供的数据脚本和插件版本历史。 迁移命令可以多次运行,它只会执行一次迁移或脚本,这意味着只应用新的更改。
php artisan october:up
反向命令october:down
将反转所有迁移,删除数据库表并删除数据。 使用此命令时应小心。 插件刷新命令是调试单个插件的有用替代方法。
php artisan october:down
插件管理
October包含许多用于管理插件的命令。
安装插件
plugin:install
- 按名称下载并安装插件。 下一个示例将安装一个名为AuthorName.PluginName的插件。 请注意,您的安装应绑定到项目以使用此命令。 您可以在October的网站上帐户/项目 部分创建项目。
php artisan plugin:install AuthorName.PluginName
刷新插件
plugin:refresh
- 破坏插件的数据库表并重新创建它们。 此命令对开发很有用。
php artisan plugin:refresh AuthorName.PluginName
删除插件
plugin:remove
- 破坏插件的数据库表并从文件系统中删除插件文件。
php artisan plugin:remove AuthorName.PluginName
主题管理
October包含许多用于管理主题的命令。
安装主题
theme:install
- 从Marketplace下载并安装主题。 以下示例将在/themes/authorname-themename
中安装主题
php artisan theme:install AuthorName.ThemeName
如果您希望在自定义目录中安装主题,只需提供第二个参数。 以下示例将下载AuthorName.ThemeName
并将其安装在/themes/my-theme
中
php artisan theme:install AuthorName.ThemeName my-theme
列出主题
theme:list
- 列出已安装的主题。 使用 -m 选项在市场中包含热门主题。
php artisan theme:list
启用主题
theme:use
- 切换活动主题。 以下示例将切换到/themes/rainlab-vanilla
中的主题
php artisan theme:use rainlab-vanilla
删除主题
theme:remove
- 删除主题。 以下示例将删除目录/themes/rainlab-vanilla
php artisan theme:remove rainlab-vanilla
实用命令
October包含许多实用程序命令。
清除应用缓存
cache:clear
- 清除应用程序,twig和combiner缓存目录。 例:
php artisan cache:clear
删除演示数据
october:fresh
- 删除October随附的演示主题和插件。
php artisan october:fresh
镜像公共目录
october:mirror
- 使用符号链接创建服务应用程序所需的公共文件的镜像副本。 设置公用文件夹时使用此命令。
php artisan october:mirror public/
启用DotEnv配置
october:env
- 将常见配置值更改为DotEnv语法。
php artisan october:env
其他命令
october:util
- 执行常规实用程序任务的通用命令,例如清理文件或合并文件。 传递给此命令的参数将确定使用的任务。
编译资源
编译输出JavaScript(js),StyleSheets(less),语言(lang)或所有(静态资源)文件。
php artisan october:util compile assets
php artisan october:util compile lang
php artisan october:util compile js
php artisan october:util compile less
要在没有缩小的情况下合并,请传参数--debug
。
php artisan october:util compile js --debug
拉取更新
这将在所有主题和插件目录上执行命令git pull
。
php artisan october:util git pull
清除缩略图
删除uploads目录中所有生成的缩略图。
php artisan october:util purge thumbs