awei01/version-controlled-wordpress 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

awei01/version-controlled-wordpress

Composer 安装命令:

composer create-project awei01/version-controlled-wordpress

包简介

Version controlled wordpress boilerplate

README 文档

README

This is an opinionated boilerplate installation of wordpress that seeks to make development and deployment more manageable by allowing everything to be under source control, including media uploads and database.

While this boilerplate should work on any operating system, this readme is written with Linux/Debian system in mind. You'll have to google alternative commands for your particular environment.

Note that on Windows environments, symlinks are kind of a pain to accomplish. You'll have to google how to resolve these.

Motivation

Wordpress was born in an age when FTP was the best tool used to publish websites. It was primarily intended for designers and not developers. As a result, maintenance and version control are a nightmare. This repository seeks to mitigate some of the headaches a developer may encounter when developing and maintaining a Wordpress installation.

This repository assumes that you are technically proficient enough to find your way around a server via a command prompt.

Default Configuration

All the following configurations can be disabled via the .env file

  • File-based caching: Store cache in the file system storage/cache instead of your wp_options table.
  • File-based database: Now you can version control your blog content. You don't have to export/import a mysql dump.
  • Upload folder outside of wp-content: Your uploads folder is located outside of wp-content. This way, you can version control your uploads.
  • Automated plugin management: Manage your plugins via composer.json without relying on the web-based installation process.
  • Disable automated updates: Core, plugins and themes updates are disabled, saving database read/writes. You now have finer control over versioning via composer.json.
  • Suppress admin menu items and widgets: Themes and plugins menu items are hidden by default since they're now managed via composer.json. Certain dashboard widgets are removed by default.

System Requirements

Note: All of the following commands are for Debian based systems.

  • A webserver: While any server should technically work with this codebase, I'm assuming Apache and provide a sample config file in /server/apache.example.conf. To install: apt-get install apache2
  • PHP >5.6: While earlier versions of PHP may work, I've developed this boilerplate using PHP 5.6.17-3. apt-get install php5
  • SQLite PDO driver: apt-get install php5-sqlite This overrides the default MySQL database. If you really want MySQL, there are ways to re-enable it.
  • Git: A version control tool. apt-get install git
  • Composer: A PHP package manager. Installation instructions

Suggested Installation

  • Install via Composer: composer create-project --prefer-dist awei01/version-controlled-wordpress <folder>
  • Change directory into your folder: cd <folder>
  • Initialize your repository so that you can start checking in your code changes: git init

When using the above step on a virtual machine, I have encountered issues with the symbolic links within the project breaking. I'm not sure why this is occurring. To fix the problem, you can try the Alternative Installation instructions or, manually fix the symlinks yourself.

Alternative Installation

  • Clone this repository: git clone https://github.com/awei01/version-controlled-wordpress.git ./<folder>
  • Change directory into your folder: cd <folder>
  • Have Composer install dependencies: composer install
  • Rename the git remote to upstream: git remote rename origin upstream
  • Initialize your repository so that you can start checking in your code changes: git remote add origin <your git url>

Continue Set Up

  • Copy .env.sample to .env and edit the values to suit your configuration
  • Ensure storage folder is recursively is writeable chmod -R 766 storage
  • Copy and edit your server/apache.example.conf into your Apache sites-enabled
  • Restart Apache
  • Browse to your domain and you should get the Wordpress installation page.
  • The default location for Wordpress admin is http://<domain>/wp/wp-admin

Required Symlinks

  • public/wp points to wp for wordpress core files
  • public/content/db.php points to modules/sqlite/init.php to use SQLite instead of MySQL
  • public/content/object-cache.php points to modules/file-cache/init.php to use file-based caching
  • public/content/plugins points to /wp-plugins for Composer managed wordpress plugins
  • public/uploads to storage/uploads for uploaded media

Composer Managed Modules

  • vlucas/phpdotenv: Allow loading environment specific configurations via flat file. https://packagist.org/packages/vlucas/phpdotenv
  • illuminate/cache: Allow for file-based caching
  • illuminate/filesystem: Allow for file-based caching
  • symfony/var-dumper: Supporting modules for illuminate/cache

Composer Managed Wordpress Plugins

These can be found on http://wpackagist.org/ or http://wordpress.org/plugins

Installing plugins/themes

Plugins and themes are now managed via the composer.json file.

  • Use http://wpackagist.org to locate your plugin or theme and add it to the require section of composer.json.
  • Run composer update from the command line to install the new dependencies.
  • If you've installed a plugin and you're using file-based caching, you'll need to delete the cache first: rm -rf storage/cache/*
  • Browse to your site again and your new plugins will be activated.

Migrating an Existing Wordpress Installation

Here are some suggestions on migrating your existing installation. These instructions all assume you're using the default configurations for this repository.

Backup

  • You should cover your ass by backing up the existing installation. Use mysqldump to get a full dump of your database. Compress and save the existing codebase, including your uploads folder.

Setup

  • Create a new local development environment using this repository.
  • Modify composer.json so that the version of johnpbloch/wordpress matches your current installation. * If you want to upgrade your Wordpress core version, I suggest doing it after migration is complete.

Plugins

  • Search for your plugins on http://wpackagist.org and add them to your composer.json. You'll probably want the exact versions that you have already installed on your existing application. If you want to try a later plugin version, you can give it a shot. It should be trivial to switch between plugin versions.
  • If you've made code-related customizations to your plugins, you can copy these directly into the wp-plugins folder and update .gitignore files so that these customizations are saved in your repository. In this case, do not add the plugin to your composer.json.

Themes

  • Same as plugins; find the appropriate module and add them to your composer.json.
  • If you've made code-related customizations to your themes, copy these directly into the wp-themes folder and update .gitignore files so that these customizations are saved in your repository.
  • If you've made theme customizations and you know you're not going to switch themes going forward, you can just copy your theme files into /theme and it will just show up as the default theme.

Preview

  • Fire up apache and browse to your local server. You will be prompted to create a new Wordpress installation.

Migrating Content

At this point, you should have a clean install of your site. Of course, your posts, pages, comments, etc., will not have been migrated yet.

Simple Export/Import

  • Leverage the default Wordpress exporting capabilities by going to the admin interface of your production environment and navigating to Tools > Export.
  • Download the export file and save it on your development machine.
  • Install the wpackagist-plugin/wordpress-importer in your composer.json on your local environment.
  • On your environment admin interface, you can now go to Tools > Import and follow the instructions to import the file you just downloaded.

Advanced Export/Import

  • Use the mysqldump script from your production environment and replicate the MySQL database locally.
  • You'll need to convert your MySQL script to SQLite somehow. I've used the tool RazorSQL (free for 30 days) with some success.
  • Copy your uploads directory into the /storage/uploads folder. Now all your images should exist on your server.

Suggestions and Pull Requests are welcomed

awei01/version-controlled-wordpress 适用场景与选型建议

awei01/version-controlled-wordpress 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 02 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「wordpress」 「version control」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 awei01/version-controlled-wordpress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 awei01/version-controlled-wordpress 我们能提供哪些服务?
定制开发 / 二次开发

基于 awei01/version-controlled-wordpress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-03