Skip to main content
nik's personal space

Main navigation

  • About
  • Profile
  • Blogs
  • Achievements
  • Reach nik
User account menu
  • Log in

Breadcrumb

  1. Home

Life saver - live dev on Magento Cloud

Not many know about this but we can do live development / debugging on Magento. I will share quickly how to do that below. Thanks to James Cowie and Sylvain Delbosc for helping me get good sleep even with blocker issues coming :D.

Once we login to Magento cloud, we get all our code in /app directory and all the code is made readonly. This makes it difficult to edit any file and add logs or change code to verify our code changes on dev server. This is really required with complex architectures where we have integrated systems and issues are with specific scenarios which are not possible to replicate in local machines.

Most of the code is in Classes and glad we are using auto loaders :). There is a scope of adding our classes in /app/app/etc/NonComposerComponentRegistration.php file before all the code to include all files (basically right after the file comment). This will ensure our classes are loaded and not the ones from actual modules.

To do this, we have to copy our files inside /app/var dir which is writeable. For instance if we want to modify anything in vendor/magento/module-customer/Model/Customer.php we just need to copy it to var

mkdir -p /app/var/vendor/magento/module-customer/Model
 
cp /app/vendor/magento/module-customer/Model/Customer.php /app/var/vendor/magento/module-customer/Model/Customer.php

and add it to /app/app/etc/NonComposerComponentRegistration.php like below.
 
<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
 
require_once('/app/var/vendor/magento/module-customer/Model/Customer.php');
 
$pathList[] = dirname(__DIR__) . '/code/*/*/cli_commands.php';

And that's it, now whatever you change in your file inside var will be executed.

Beware, this will be reverted back on next deployment. But we only want it to be temporary change for debugging or verifying code change so should be good.

PS - we can also enable XDEBUG if there is bigger issue to debug, there is good documentation available here.
 
Behat tests with Lando and Apple M1
Knowledge required as PHP developer
Drupal - Tips to keep browser CPU usage in check
Thinking about customer success as a developer
Developing or testing Apple Pay
Being pro-active as developer
Effective communication, how I do it
Migrating multi-value non-associative data
Drupal 8: Reverting features in update hooks
Drupal 8: Updating field configuration in update hooks
Certified SAFe® 6 Agilist Badge
BMI IQ - 135
Acquia Certified Cloud Pro 2020
Acquia Certified Front End Specialist - Drupal 9
Triple Certified Drupal Expert - Drupal 9
Acquia Certified Developer - Drupal 9
Acquia Certified Site Studio 6 Site Builder
Acquia Certified Back End Specialist - Drupal 9
Acquia Certified Site Factory Pro
Acquia Certified Developer - Drupal 8
Acquia Certified Developer - Drupal 7
Certified ScrumMaster®
Powered by Drupal