These notes cover the steps to follow in order to upgrade major versions of the framework.
Follow the steps below if you're using version 1.2.x and want to upgrade to version 1.3.0. Version 1.3.0
has many code breaking changes, so take extra care to each step. We recommend you to upgrade your project using another branch and merge it once complete. For this update, you'll need to upgrade the root files, your custom theme root files and code and finally run a tiny database query in order to make your existing project work with the Themosis framework 1.3.0
.
- Rename the
bootstrap/start.php
file intobootstrap/autoload.php
. - Replace the
bootstrap/autoload.php
file content with this one. - Replace the
config/shared.php
content with this file. - Update your
config/environments/local.php
file accordingly based on the new one. - Remove deprecated environments constants from all of your environments files (local, staging, production, ...):
THEMOSIS_ERROR_DISPLAY
THEMOSIS_ERROR_SHUTDOWN
THEMOSIS_ERROR_REPORT
- If you use any of these deprecated constants, be sure to update your project accordingly.
- Replace
htdocs/wp-config.php
file with this one. - Replace
library/Thms/Config/Environment.php
class content with this updated class. - Add a
twig
sub-folder into thestorage
directory. - Remove the
.php
extension to all of your.env.{location}
files. - Update all
.env.{location}
files content based on the DotEnv package syntax. Here is an example of the default.env.local
file to help you update your code. - Update the root
composer.json
file based on the framework new one and update yourrequire
statements based on your project needs. - Before running an update, verify that your current developed theme folder is not named
themosis-theme
otherwise it will be overwritten. In some cases, you must also delete yourcomposer.lock
andthemosis-framework
folder in order to get latest and overwrite cached versions. - Open your command line or console and update your composer installation by running first a
composer self-update
then update your project dependencies by runningcomposer update
. This will install all new framework dependencies.
If you have followed the previous steps, the framework core is up-to-date and a copy of the new themosis-theme
has been installed as well into your themes directory for reference. The following steps will guide through the files to update, remove and move in order to make your custom theme compatible.
- Remove the
bootstrap
folder. - From the new
themosis-theme
, copy itsfunctions.php
file and replace your theme’sfunctions.php
file. - Remove all the code from your theme
index.php
file. Leaving the file empty. - Remove all theme
index.php
files placeholders except theindex.php
file located at theme’s root. - Add a
languages
folder in your theme root in order to load your translation files if any. - Move the
assets
folder located inside theresources
directory to your theme’s root. - At theme's root, create a
dist
folder and addcss
,images
andjs
folders into it. - If you don't have one already, copy the
package.json
file from thethemosis-theme
into yours. - If you don't already use Gulp, copy the
gulpfile.js
file from thethemosis-theme
into yours. - If you don't already have a
webpack.config.js
file, copy thewebpack.config.js
file from thethemosis-theme
into yours. - (optional) New theme is bundled with Gulp and Webpack to handle assets. If you have existing Gulpfile, Bower,… configuration files, it’s optional to update them but Gulp is configured to look for assets inside the
assets
folder and compile them into thedist
directory. - (optional) Move your previously compiled CSS files into the new
dist/css
directory. - (optional) Move your previously compiled JS files into the new
dist/js
directory. - Find and replace all references of the
themosis_assets()
function with thethemosis_theme_assets()
function. - Rename the
application.config.php
file totheme.config.php
. - Update the
theme.config.php
alias property with new one. Do not forget to add your custom aliases if previously defined. - Copy the
themosis-theme
providers.config.php
file inside your theme’sresources/config
directory. - Copy the
themosis-theme
resources/providers
directory and its content into your theme'sresources
folder. - Update the
loading.config.php
file and replace all instances of the previous paththemosis_path(‘theme’)
bythemosis_path(‘theme.resources’)
- The new theme use a default PHP namespace,
Theme\\
. Append the service providers auto-loading rule into yourloading.config.php
file:'Theme\\Providers\\' => themosis_path('theme.resources').'providers'
. - Update your models loading namespace key to
Theme\\Models\\
. - Update your controllers loading namespace key to
Theme\\Controllers\\
. - Update all your controllers and models classes to use the new theme namespace. For example on controllers classes:
namespace Theme\Controllers;
. If you already use custom namespaces for your theme, keep it and update files accordingly. - (optional) If you already use custom namespace for your controllers, you have to update the
resources/providers/RoutingService
namespace in order to correctly use your controllers within the routes. Find and replace the'Theme\Controllers'
by your into the Route group method namespace property. - Inside your
resources/routes.php
file, update your controller classes references to only their class name without the namespace. For example, if you had a class controller full name ofCompany\Awesome\Controller\Pages@show
, such parameter would be nowPages@show
. - The
BaseController
class is no longer bundled within the theme. Please define its path by adding the following use statement at the top of each of your controller classes:use Themosis\Route\BaseController;
. - Find and replace all instances of the
THEMOSIS_TEXTDOMAIN
constant byTHEME_TEXTDOMAIN
constant. Make sure to check your config files as well. - The
Session::nonceName
andSession::nonceAction
constants have been removed. If you used them into your code, please define your own nonces. - The PostType
getSlug()
method is deprecated. Update your code and use theget(‘name’)
method. - The Form
checkboxes()
method is deprecated. Update your code to use thecheckbox()
method instead. - Rename all your view files to now use the
.blade.php
extension in place of the deprecated.scout.php
extension. - The directive
{{ }}
prints and escapes values now and the{!! !!}
directive only prints the value. Update your views accordingly to avoid HTML content being escaped like the post content for example. - For those using the Themosis page templates, the current version is now using WordPress core templates. Meaning that all the code referencing the meta key
_themosisPageTemplate
must be updated and reference the meta key_wp_page_template
. Once your code updated, please refer to the last step below in order to update yourpostmeta
database table.
For users who were working on the master branch, please update all references of
container('config')
or$theme['config']
bycontainer('config.factory')
and$theme['config.factory']
accordingly from your themefunctions.php
file.
Since the framework now uses the WordPress core template system. You need to update your database postmeta
table in order for your code to find the right page template. Open a MySQL console and run the following query (please change table name based on your database prefix):
UPDATE wp_postmeta SET meta_key = '_wp_page_template' WHERE meta_key = '_themosisPageTemplate';
- Done! Congratulations.
Follow the steps below if you're using version 1.2.x and want to upgrade to version 1.2.3.
Note:
Habitually minor release doesn't need a manual process but this one is an exception in order to fix the PHP class alias issue. Since release 1.2.0, class aliases have been moved from the theme to the core plugin. The idea behind this was to provide core aliases to the theme but as well to custom plugins.
But we have an issue. Defining class aliases into plugin is prone to conflicts between plugins and the currently active theme. After testing some ideas to avoid name conflicts, it was clear that plugins won't be able to define class aliases or put in other words, won't be allowed to define class aliases using the PHP class_alias function. Developers will have to use PHP namespace and its features for the development of their plugins.
Please note that plugin development is still in its infancy with the framework. Plugin development with full documentation will be available for release 1.3.0. only.
In the meantime, update your project and follow the steps below to get version 1.2.3:
- Be sure your working theme has been renamed to something else than
themosis-theme
. - Open the Console or Terminal and run
composer update
from your project root. - Replace your theme's
bootstrap/start.php
file by this one. - Open your theme's
config/application.config.php
file and update thealiases
property with the array list from this gist. - Upgrade complete.
Follow the steps below if you're using version 1.1.x and want to upgrade to version 1.2.0.
- Create a
storage
folder at project root (same location as your main composer.json file). - Inside the
storage
folder, create aviews
directory. - Update your
composer.json
file and set yourthemosis-framework
andthemosis-theme
version to1.2.*
. - Run
composer update
. - Update the
start.php
file located inside thebootstrap
folder at project root with this file. - Next, in your theme, replace
functions.php
file by the one found in the new installed themosis-theme. - Rename your theme
app
folder toresources
. - Copy the
bootstrap
folder from the new installed themosis-theme into your own theme. - Update your
loading.config.php
file by the one found in the new installed themosis-theme. PSR-4 autoloading is used in this version. Update your custom classes autoloading statements accordingly. - Aliases defined inside
application.config.php
are now by default defined inside the core framework at least for core classes. You can override their aliases or add yours for your custom classes. If you don't have any custom aliases, you can specify an empty array by default. - The Field API has been rewritten. If you have
select
andeditor
fields, check the new field documentation and update those fields as their arguments have been changed. - Delete the installed
themosis-theme
. - Upgrade complete. Enjoy!
Check the change log page for a list of new features and fixes available. Also, the documentation has been completely rewritten for this release with more examples, make sure to check it out.
If you have an error with your views storage, your project is missing the constant
THEMOSIS_STORAGE
. Please check step 5 above to fix this.