These notes cover the steps to follow in order to upgrade major versions of the framework.
The Themosis framework 2.0 is not a backward compatible release. It does share some API with previous releases but as its directory structure has changed, you need to move your code with extra care.
The recommended way of upgrading an existing application to a 2.0 release is to create a new 2.0 project and move parts one by one. Here are general steps to look after in order to upgrade your application:
composer create-project themosis/themosis your-app-name
..env
file based on your application needsconfig/environments/local-or-production.php
to the new config/wordpress.php
file.php console theme:install your-theme-name
.routes/web.php
.app/Http/Controllers
. Take care of changing the default namespace of your classes to App\Http\Controllers
.composer.json
file and update. Move specific business PHP classes, if any, inside the app
directory and change their namespace accordingly.views
directory defined at theme's root.admin
files into the new theme inc
folder.config
files into the new theme config
folder located at theme's root.app/Widgets
directory and register them within the app/Hooks/Widgets.php
file.to()
method on each instance. The to
method default to the front
end side.THEME_TD
constant and update gettext files accordingly.themosis_front_global
.If you developed custom plugins on previous releases using the plugin boilerplate, those are no longer compatible with the 2.0 release. Plugin configuration has been simplified and is more straightforward. Just like the theme, it is best to start a new plugin and move parts one by one:
php console plugin:install your-plugin-name
to start a new pluginThe plugin structure follows the same file organisation than the theme. Make sure to read the plugin guide for more information.
media
and collection
fields only work with a metabox instanceset
method. Please check the documentation for each API if you use them.infinite
field is no longer included within the framework for nowFollow 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
.
bootstrap/start.php
file into bootstrap/autoload.php
.bootstrap/autoload.php
file content with this one.config/shared.php
content with this file.config/environments/local.php
file accordingly based on the new one.THEMOSIS_ERROR_DISPLAY
THEMOSIS_ERROR_SHUTDOWN
THEMOSIS_ERROR_REPORT
htdocs/wp-config.php
file with this one.library/Thms/Config/Environment.php
class content with this updated class.twig
sub-folder into the storage
directory..php
extension to all of your .env.{location}
files..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.composer.json
file based on the framework new one and update your require
statements based on your project needs.themosis-theme
otherwise it will be overwritten. In some cases, you must also delete your composer.lock
and themosis-framework
folder in order to get latest and overwrite cached versions.composer self-update
then update your project dependencies by running composer 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.
bootstrap
folder.themosis-theme
, copy its functions.php
file and replace your theme’s functions.php
file.index.php
file. Leaving the file empty.index.php
files placeholders except the index.php
file located at theme’s root.languages
folder in your theme root in order to load your translation files if any.assets
folder located inside the resources
directory to your theme’s root.dist
folder and add css
, images
and js
folders into it.package.json
file from the themosis-theme
into yours.gulpfile.js
file from the themosis-theme
into yours.webpack.config.js
file, copy the webpack.config.js
file from the themosis-theme
into yours.assets
folder and compile them into the dist
directory.dist/css
directory.dist/js
directory.themosis_assets()
function with the themosis_theme_assets()
function.application.config.php
file to theme.config.php
.theme.config.php
alias property with new one. Do not forget to add your custom aliases if previously defined.themosis-theme
providers.config.php
file inside your theme’s resources/config
directory.themosis-theme
resources/providers
directory and its content into your theme's resources
folder.loading.config.php
file and replace all instances of the previous path themosis_path(‘theme’)
by themosis_path(‘theme.resources’)
Theme\\
. Append the service providers auto-loading rule into your loading.config.php
file: 'Theme\\Providers\\' => themosis_path('theme.resources').'providers'
.Theme\\Models\\
.Theme\\Controllers\\
.namespace Theme\Controllers;
. If you already use custom namespaces for your theme, keep it and update files accordingly.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.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 of Company\Awesome\Controller\Pages@show
, such parameter would be now Pages@show
.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;
.THEMOSIS_TEXTDOMAIN
constant by THEME_TEXTDOMAIN
constant. Make sure to check your config files as well.Session::nonceName
and Session::nonceAction
constants have been removed. If you used them into your code, please define your own nonces.getSlug()
method is deprecated. Update your code and use the get(‘name’)
method.checkboxes()
method is deprecated. Update your code to use the checkbox()
method instead..blade.php
extension in place of the deprecated .scout.php
extension.{{ }}
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._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 your postmeta
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';
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:
themosis-theme
.composer update
from your project root.bootstrap/start.php
file by this one.config/application.config.php
file and update the aliases
property with the array list from this gist.Follow the steps below if you're using version 1.1.x and want to upgrade to version 1.2.0.
storage
folder at project root (same location as your main composer.json file).storage
folder, create a views
directory.composer.json
file and set your themosis-framework
and themosis-theme
version to 1.2.*
.composer update
.start.php
file located inside the bootstrap
folder at project root with this file.functions.php
file by the one found in the new installed themosis-theme.app
folder to resources
.bootstrap
folder from the new installed themosis-theme into your own theme.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.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.select
and editor
fields, check the new field documentation and update those fields as their arguments have been changed.themosis-theme
.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.
Made in Belgium