Merge pull request #7985 from open-sausages/pulls/4/appy-days

DOCS Upgrading notes for app/src folder
This commit is contained in:
Damian Mooyman 2018-04-11 15:16:38 +12:00 committed by GitHub
commit 741a7f200c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View File

@ -43,7 +43,8 @@ through the [Composer dependency update section](/changelogs/4.0.0#deps)
* Backup your database content.
* Backup your webroot files.
* Download the new release and uncompress it to a temporary folder.
* Leave custom folders like *mysite* or *themes* in place.
* Leave custom folders like *themes* in place.
* Rename `mysite/code` folder to `app/src`, updating your `app/_config/mysite.yml` config to set the new project name.
* Identify system folders in your webroot (`cms`, `framework` and any additional modules).
* Delete existing system folders (or move them outside of your webroot).
* Add a `private static $table_name = 'MyDataObject'` for any custom DataObjects in your code that are namespaced. This ensures that your database table name will be `MyDataObject` instead of `Me_MyPackage_Model_MyDataObject` (converts your namespace to the table_name).
@ -99,7 +100,7 @@ For a full list of renamed classes, check the `.upgrade.yml` definitions in each
After installing, run the upgrader upgrade command:
```
cd ~/my-project-root
~/.composer/vendor/bin/upgrade-code upgrade ./mysite --write
~/.composer/vendor/bin/upgrade-code upgrade ./app/src --write
```
## Migrating files

View File

@ -7,6 +7,49 @@
## Upgrading {#upgrading}
### App folder name
The standard 'mysite' code naming convention has changed in 4.2. Although existing sites can continue
to use 'mysite/code` to store their base project code, the recommendation and new default is to
store code in `app/src`.
Additionally, we reinforce the recommendation to use psr-4 autoloading in your project to speed up
class loading.
In order to upgrade a site to use `app/src` folder:
- Rename the folder `mysite` to `app` and `code` to `src`.
- Update your `app/_config/mysite.yml` config to the below:
```yaml
---
Name: myproject
---
SilverStripe\Core\Manifest\ModuleManifest:
project: app
```
- add psr-4 for your root project files and namespace. An example `composer.json` below
shows how this might look:
```json
{
"autoload": {
"psr-4": {
"TractorCow\\MyWebsite\\": "app/src/"
},
"classmap": [
"app/src/Page.php",
"app/src/PageController.php"
]
}
}
```
- Ensure you flush your site with `?flush=all`
Note: In 5.0 the app folder will be fixed to `app` and cannot be soft-coded via `mysite.yml`
### Disable session-based stage setting
When viewing a versioned record (usually pages) in "draft" mode,