# Rector to Upgrade Bootstrap

**URL:** <https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790>\
**Category:** Uncategorized\
**Created:** [January 10, 2024, 8:14am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790 "2024-01-10T08:14:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yousuo](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yousuo](https://discourse.cakephp.org/u/yousuo)\
**Post date:** [January 10, 2024, 8:14am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790/1 "2024-01-10T08:14:31Z")

</div>

I read the upgrade [cake5 guide](https://book.cakephp.org/5/en/appendices/5-0-upgrade-guide.html). I upgraded from 4.5 → 5.0 and had this error when trying to bake a model

```auto
ubuntu@ip-172-31-5-93:/var/www/html/test1$ bin/cake bake model -v --no-test --no-fixture Areas
PHP Fatal error: Uncaught Error: Call to undefined function env() in /var/www/html/test1/config/app.php:20
Stack trace:
#0 /var/www/html/test1/vendor/cakephp/cakephp/src/Core/Configure/Engine/PhpConfig.php(84): include()
#1 /var/www/html/test1/vendor/cakephp/cakephp/src/Core/Configure.php(346): Cake\Core\Configure\Engine\PhpConfig->read()
#2 /var/www/html/test1/config/bootstrap.php(83): Cake\Core\Configure::load()
#3 /var/www/html/test1/vendor/cakephp/cakephp/src/Http/BaseApplication.php(183): require_once('...')
#4 /var/www/html/test1/src/Application.php(69): Cake\Http\BaseApplication->bootstrap()
#5 /var/www/html/test1/vendor/cakephp/cakephp/src/Console/CommandRunner.php(190): App\Application->bootstrap()
#6 /var/www/html/test1/vendor/cakephp/cakephp/src/Console/CommandRunner.php(137): Cake\Console\CommandRunner->bootstrap()
#7 /var/www/html/test1/bin/cake.php(12): Cake\Console\CommandRunner->run()
#8 {main}
  thrown in /var/www/html/test1/config/app.php on line 20

```

After troubleshooting, I found that I needed to update the `bootstrap.php` file with this line

```auto
/**
 * Load global functions.
 */
require CAKE . 'functions.php';

```

Shouldn’t this be done using the upgrade tool ?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [January 10, 2024, 9:38am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790/2 "2024-01-10T09:38:40Z")

</div>

The upgrade guide explicitly says at the bottom that you have to [compare your app template](https://book.cakephp.org/5/en/appendices/5-0-upgrade-guide.html#update-app-files-based-upon-latest-app-template) with the current state of the app template.

This is not something we can easily do with the rector tool.

---

<div class="post-metadata">

**Author:** ![yousuo](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yousuo](https://discourse.cakephp.org/u/yousuo)\
**Post date:** [January 11, 2024, 3:01am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790/3 "2024-01-11T03:01:56Z")

</div>

Yes, I saw that part. I wasn’t so sure what the template files were.

Are they all the files in the `config` folder (e.g. bootstrap.php, app.php) ?

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [January 11, 2024, 7:17am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790/4 "2024-01-11T07:17:40Z")

</div>

There aren’t that many files in the app template, so I’d just recommend you invest the 15 minutes and compare each file from the app template with your own app and copy things over if they are missing.

---

<div class="post-metadata">

**Author:** ![yousuo](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yousuo](https://discourse.cakephp.org/u/yousuo)\
**Post date:** [January 12, 2024, 7:07am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790/5 "2024-01-12T07:07:10Z")

</div>

I guess the fastest way is to copy the app-template files into phpstorm, and compare (control+D) them. 15 minutes would not be enough for all the files in here: [GitHub - cakephp/app: CakePHP application template](https://github.com/cakephp/app/tree/5.x)

I think this part needs improvement, especially when cakephp files on my server and needs to be updated 1-by-1.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [January 12, 2024, 11:18am UTC](https://discourse.cakephp.org/t/rector-to-upgrade-bootstrap/11790/6 "2024-01-12T11:18:53Z")

</div>

if you know when you created your cakephp app you can also open the compare tool in github and just apply these changes

> **[Comparing 4.5.0...5.0.0 · cakephp/app](https://github.com/cakephp/app/compare/4.5.0...5.0.0)**
>
> CakePHP application template. Contribute to cakephp/app development by creating an account on GitHub.

this is just how it works because this is an app template which gets created at the spot when you execute `composer create-project --prefer-dist cakephp/app`

If you can think of a better way to get an (automated) update process working for such file changes please feel free to create a github issue.
