Skip to main content

How to upgrade Cakephp 3 to Cakephp 4.x

How to upgrade Cakephp 3 to Cakephp 4.x


So Cakephp 4 is released and now cakephp did major changes is that :

1. Now cakephp using more typehinting and strict mode.
2. cakephp replaced .ctp file extension with .php so now all tempalates files have .php extension .
3. Now templates folder moved from src to root folder.
4. Some functions are now deprecarted that you can check on its official website .

Now today we learn how to upgrade Cakephp version to latest version. So keep follow below steps:-

1) Open terminal and go to the root directory folder

2) Then run below command to install upgrade tool
  
   git clone git://github.com/cakephp/upgrade


3) Now above command will create upgrade folder in your root directory so change drive by using below command

cd upgrade


4. Now we need to install new files of cake 4 so run below command:
git checkout 4.x


5. Now run below command
composer install --no-dev


Ok so now we have all new updated file so now we need to change our old templates files extension to php also move folder to root, so for that we will run below commands in upgrade directory

Rename locale files
bin/cake upgrade file_rename locales ../


Rename template files
bin/cake upgrade file_rename templates ../


Above two command will make changes in your current project according to new cake version, then you need to change you update App.paths.locales and App.paths.templates paths to be correct.Then proceed to next step.

Now we need to run rector command so it can fix deprecated functions

bin/cake upgrade rector --rules phpunit80 ../tests

bin/cake upgrade rector --rules cakephp40 ../src



Now we need to upgrade all cakephp dependencies, so for that please run below commands:
composer require --update-with-dependencies "phpunit/phpunit:^8.0"

composer require --update-with-dependencies "cakephp/cakephp:4.0.*"


Note if your composer not installed globally then above command will show error so please run below command
php composer.phar require --update-with-dependencies "phpunit/phpunit:^8.0"

php composer.phar require --update-with-dependencies "cakephp/cakephp:4.0.*"



Ok so if you run all commands successfully then now you can run frontend and you can see now your cakephp version is updated to cakephp 4

Thanks for the reading. :)


Related Links

Install cakephp 4

Upgrade Cakephp to latest version

Update cakephp version in linux/windows

Upgrade cakephp 4 thorugh terminal/cmd

How to upgrade cakephp 3 to cakephp 4 with commands

Comments

  1. Can you show how to migrate from cakephp 2.10.5 to cakephp 4? It will be really helpful

    ReplyDelete
  2. Your Affiliate Money Printing Machine is waiting -

    And making money with it is as simple as 1---2---3!

    Here is how it works...

    STEP 1. Tell the system what affiliate products the system will promote
    STEP 2. Add some PUSH button traffic (this LITERALLY takes 2 minutes)
    STEP 3. Watch the affiliate products system grow your list and sell your affiliate products on it's own!

    Are you ready to start making money??

    You can test-drive the system for yourself risk free...

    ReplyDelete
  3. Your Affiliate Money Making Machine is waiting -

    And making money online using it is as simple as 1-2-3!

    Here are the steps to make it work...

    STEP 1. Input into the system what affiliate products the system will push
    STEP 2. Add some push button traffic (it LITERALLY takes JUST 2 minutes)
    STEP 3. Watch the affiliate system grow your list and sell your affiliate products for you!

    So, do you want to start making profits???

    You can test-drive the system for yourself risk free...

    ReplyDelete
  4. According to Stanford Medical, It's indeed the ONLY reason this country's women live 10 years longer and weigh 42 lbs less than we do.

    (By the way, it has totally NOTHING to do with genetics or some secret-exercise and EVERYTHING related to "HOW" they are eating.)

    P.S, What I said is "HOW", not "what"...

    CLICK this link to determine if this easy test can help you unlock your true weight loss possibility

    ReplyDelete
  5. Your Affiliate Profit Machine is ready -

    And getting it set up is as simple as 1--2--3!

    It's super easy how it works...

    STEP 1. Input into the system which affiliate products the system will advertise
    STEP 2. Add some PUSH button traffic (it takes JUST 2 minutes)
    STEP 3. Watch the system explode your list and sell your affiliate products all on it's own!

    Do you want to start making money???

    Click here to activate the system

    ReplyDelete
  6. It was a nice article. could you please show how to upgrade Cakephp 2.x-> CakePhP 3.x.
    It would be appreciated.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

Run and compile sass scss file to css using node

  Today we learn how to use scss and generate css using node  or Run and compile sass scss file to css using node   So please follow simple  steps :-   Today we will create a project that can read scss file and generates css with it  Note: Make sure you have installed node in your system. If you want to help to install node js based on your system then check our other tutorial or check node js official website. Now create a blank folder and open  terminal(linux) or cmd(windows) and navigate to your current project folder by using cd command Now run below command npm init after enter it will ask you some package info that you can fill according to you or just keep enter until it finished. The above command will generate package.json file Now  we will install npm module that will convert our scss to css Run below command: npm install node-sass So we have installed node-sass package . Now open package.json file in your...

How to retrieve Facebook Likes, share , comment Counts

function facebook_count($url){     // Query in FQL     $fql  = "SELECT share_count, like_count, comment_count ";     $fql .= " FROM link_stat WHERE url = '$url'";     $fqlURL = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);     // Facebook Response is in JSON     $response = file_get_contents($fqlURL);     return json_decode($response); } $fb = facebook_count('https://www.facebook.com/BahutHoGyiPadhai'); // facebook share count echo $fb[0]->share_count;  echo "like"; // facebook like count echo $fb[0]->like_count ; echo "comment"; // facebook comment count echo $fb[0]->comment_count;  ?>

Solution-windows 'expo' is not recognized as an internal or external command

Solution for expo is not recognized as an internal or external command,operable program or batch file in Windows 10 Sometimes expo will not work globally mostly in windows 10, If you are facing same issue then follow the below Steps 1) Click on windows button and search for  " Environment variables"  and click on "Edit the system environment variables" 2) Now you will see a popup like below screen. Then you need to click on Environment Variables. (Please see highlight part in below image)     3)Then click on new button that i have highlighted in below image 4. Then a popup will open and you need to fill details like below mentioned Variable Name :Path Variable Value: %USERPROFILE%\AppData\Roaming\npm Here we are creating a new path variable and passing location of npm.   Now Click on OK and close all the terminal windows and open new CMD or terminal and type Expo . Great now you can access expo from any...