ByteBard 在 Windows 使用工具的訣竅

Facebook Twitter LinkedIn LINE Skype EverNote GMail Yahoo Email

前言

This article illustrates the usage of our utility scripts on Windows family systems.

選移本地端 Lightweight CMS 網站

Invoke the following command:

$ .\tools\bin\migrate.bat

The utility script will create site configuration files and posts directory.

不使用 IIS、Apache 或 Nginx 運行本地端 Lightweight CMS 網站

Traditionally, PHP programmers install a web server to run PHP scripts locally. Nonetheless, it is not easy for beginners to write correct configurations for those web servers. With our utility script, you don't need to set up a local web server to run your PHP scripts.

Run this command to run a Lightweight CMS site locally:

> .\tools\bin\serve.bat

By default, this development web server runs on http://localhost:5000. To run a web server on other location, add your location as a parameter:

> .\tools\bin\serve.bat localhost:3000

Internally, this utility script runs a builtin web server of PHP. This feature is available after PHP 5.4 (ref).

編譯靜態 Lightweight CMS 網站

Invoke the following command:

> .\tools\bin\compile.bat

發佈 Lightweight CMS 到 PaaS

Run the Unix command to prepare your deployment:

$ ./tools/bin/publish

We implement this script in POSIX shell because most PaaS are based on GNU/Linux. If you choose a Windows PaaS, run this script instead:

> .\tools\bin\publish.bat

These utility scripts will copy router of Lightweight CMS and assets to public directory, ready for further step(s) to deploy your site.

See this article for information related to deploy a Lightweight CMS site to a PaaS.

在生產環境同步內容

Let's say you run an local Nginx web server on Laragon. Run this command to update your change(s) on a production environment:

> .\tools\bin\sync-to.bat c:\laragon\www\lightweight-cms\

Internally, this utility script runs rsync(1). Therefore, don't edit anything on your production environment.

Keep a trailing slash on your target path. It is required for rsync(1) to work properly.

在專案結構更動後更新網站設置

Run this command to update site settings each time you change project structure of your Lightweight CMS repo:

> .\tools\bin\init.bat

Site settings of Lightweight CMS is recorded in PHP scripts, which are unusable in other scripting languages. To address this issue, we generate a usable settings for Batch.

為什麼某些工具在 Windows 無法取得?

Most PHP developers develop PHP web applications on Unix-equivalent systems. Our utility scripts for Windows intend to run Lightweight CMS sites locally on Windows, not to develop Lightweight CMS itself.