TLDR
- use Docker setup to easily dev
- Use Mac with Silicon
- Install
php@8.4- Run
brew install php@8.4 - Bonus:
brew install brew-php-switcherfor easy php version switching
- Run
- Use
orbstackfor running docker containers- Why? because
webdevops/php-apache-dev:8.4doesn't work on ARM64 because of its apached ssl failing. see this issue. Weirdly, testing in orbstack works. - Run
brew install orbstack - Run
Orbstackin Application
- Why? because
- Clone
magento2in./docker-magento/- Run
git clone https://github.com/magento/magento2.git git checkout 2.4.8- This will take some time
- Run
- Add local domain
- Why? this is needed to match the
base-url-securelater on magento installation. - Run
sudo -- sh -c "echo '127.0.0.1 magento24.local' >> /etc/hosts"
- Why? this is needed to match the
- Setup magento dependencies (e.g. elasticsearch, mysql, php)
docker-compose up -d --build- Notes
- PHPMyAdmin URL @
http://localhost:8080 - Visit ElasticSearch @
http://localhost:9200to check if healthy- Note: ran into a situation it gets stuck and needs to be restarted
webservice has volume binded frommagento2to itsappdirectory, thusmagento2used in the docker container is the clonedmagento2and changes are synced over.
- PHPMyAdmin URL @
- Install Magento2.4
- Go in the docker container
docker exec -it web bash - Go to the "magento folder" by
cd app - Run the command here inside container
- Go in the docker container
- Install Xendit Module
- Run
./bin/sync-plugin.sh- This copies over Xendit M2Invoice module to desired location for Magento module and syncs it one way when changes are made. Useful for development
- Run
php bin/magento module:status.- You should see Xendit as a disabled module
- Run
php bin/magento module:enable Xendit_M2Invoiceto enable.
- Run
- Compile and Build
- Note: These steps need to be repeated when adding new modules or packages etc.
- Automated Step
- Run the script
./bin/setup-compile.shinside docker
- Run the script
- Manual Steps
php bin/magento cache:cleanphp bin/magento setup:upgradephp bin/magento setup:di:compile- Note: you might need to run
rm -rf generatedif you get an error that cannot overwrite/app/generated
- Note: you might need to run
php bin/magento cache:flushphp bin/magento setup:static-content:deploy -f
- To check
- Open
https://magento24.localin your browser- Important to use
httpsashttpmight direct you to your Mac's local apache httpd
- Important to use
- Open
- Add Sample Data
- Note: this is so your store have products. useful for dev
- Run
composer config repositories.0 composer https://repo.magento.cominside docker containerwebinappdirectory - Run
php bin/magento sampledata:deploy- (optional) If you encounter
curl error 28 while downloading https://repo.packagist.org/packages.json: Failed to connect to repo.packagist.org port 443 after 10007 ms: Timeout was reachedwhen downloading from composer, you may need to run this command first before retryingcomposer config -g repo.packagist composer https://packagist.org
- (optional) If you encounter
- Run
php bin/magento setup:upgrade - Run
rm -rf generated && php bin/magento setup:upgrade && php bin/magento cache:clean - Visit
https://magento24.localto see the products of sample data
- Check if Magento us running and Have xendit
- Open
https://magento24.local/admin/ - Login username:
adminpassword:abcd1234 - Navigate to
Stores (sidebar) > Configuration > Sales > Payment Methods - In the
Other Payment Methods, you should seeXendit - See image
- Open
- Generate Xendit Public and Private Key
- Have a xendit test account
- Go to
Xendit Dashboard > Settingscreate Private API Key - Copy both public and private key
- Set it up in Magento
- Go to Magento Admin
- Navigate to
Stores (sidebar) > Configuration > Sales > Payment Methods - Go to
Xenditand input the public and private key
- Setup custom callback url to receive payment notification
- Modify
magento2/etc/env.phpto'MAGE_MODE' => 'developer'instead ofdefault- Another way is to run
php bin/magento deploy:mode:set developer
- Another way is to run
- Install a tunneling tool like ngrok:
brew install ngrok - Start ngrok to tunnel your local Magento:
ngrok http https://magento24.local - Copy the HTTPS ngrok URL (e.g.,
https://abc123.ngrok.io) - In Magento Admin, go to
Stores > Configuration > Sales > Payment Methods > Xendit - Set the "Custom Callback URL" field to your ngrok URL (e.g.,
https://abc123.ngrok.io) - Now xendit payment links webhooks will be sent to your local development environment
3.5 (Optional) Change
Xendit Callback URL - If you plan to connect to xendit's staging environment, you have to change this. Ask Xendit Engineers on TPI Gateway Staging URL
- Modify
- Do test payment
- Open
https://magento24.local - Buy anything. Add to Cart. Fill up shipping.
- Pick
mandiri vaand you will get redirect to Xendit Payment Link - Click
Simulate Payment in the banner - After you will get redirected back, and should see a success.
- Open
- Run
./bin/sync-plugin.shto sync changes when developing - When you have changes on config files (e.g. xml)
- Run
php bin/magento cache:flush && php bin/magento setup:upgradethen refresh browser to see changes
- Run
In WebsiteRepository.php line 159:
The default website isn't defined. Set the web
site and try again.
- this probably happens if u recreate the docker container
- delete all cache and env generated by previous setup
docker exec web bash -c "cd app && rm -rf app/etc/env.php app/etc/config.php var/cache/* var/page_cache/* var/session/* var/di/* var/generation/* var/view_preprocessed/* pub/static/* generated/*"
php bin/magento setup:install \
--cleanup-database \
--admin-firstname=Admin \
--admin-lastname=TPI \
--admin-email=tpi@admin.com \
--admin-user=admin \
--admin-password=abcd1234 \
--base-url=https://magento24.local \
--base-url-secure=https://magento24.local \
--backend-frontname=admin \
--db-host=mysql \
--db-name=magento \
--db-user=root \
--db-password=root \
--use-rewrites=1 \
--language=en_US \
--currency=IDR \
--timezone=Asia/Jakarta \
--use-secure-admin=1 \
--admin-use-security-key=1 \
--session-save=files \
--use-sample-data \
--search-engine=elasticsearch8 \
--elasticsearch-host=elasticsearch \
--elasticsearch-port=9200
You can also get the sample data by adding several package from composer, add this package into your composer.json installation
"magento/module-bundle-sample-data": "100.4.*",
"magento/module-catalog-rule-sample-data": "100.4.*",
"magento/module-catalog-sample-data": "100.4.*",
"magento/module-cms-sample-data": "100.4.*",
"magento/module-configurable-sample-data": "100.4.*",
"magento/module-customer-sample-data": "100.4.*",
"magento/module-downloadable-sample-data": "100.4.*",
"magento/module-grouped-product-sample-data": "100.4.*",
"magento/module-msrp-sample-data": "100.4.*",
"magento/module-offline-shipping-sample-data": "100.4.*",
"magento/module-product-links-sample-data": "100.4.*",
"magento/module-review-sample-data": "100.4.*",
"magento/module-sales-rule-sample-data": "100.4.*",
"magento/module-sales-sample-data": "100.4.*",
"magento/module-swatches-sample-data": "100.4.*",
"magento/module-tax-sample-data": "100.4.*",
"magento/module-theme-sample-data": "100.4.*",
"magento/module-widget-sample-data": "100.4.*",
"magento/module-wishlist-sample-data": "100.4.*",
"magento/sample-data-media": "100.4.*"
and run
composer update
Local Host setup
sudo -- sh -c "echo '127.0.0.1 magento23.local' >> /etc/hosts"
Installation Command
php bin/magento setup:install \
--admin-firstname=Admin \
--admin-lastname=TPI \
--admin-email=tpi@admin.com \
--admin-user=admin \
--admin-password='abcd1234' \
--base-url=https://magento23.local \
--base-url-secure=https://magento23.local \
--backend-frontname=admin \
--db-host=mysql \
--db-name=magento \
--db-user=root \
--db-password=root \
--use-rewrites=1 \
--language=en_US \
--currency=IDR \
--timezone=Asia/Jakarta \
--use-secure-admin=1 \
--admin-use-security-key=1 \
--session-save=files \
--use-sample-data
If you encounter this problem when trying to install Magento inside docker
Fatal error: Uncaught Error: Call to undefined function xdebug_disable()
Go to this directory (after finished installing dependencies)
vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php
Replace this line
xdebug_disable();
Into
if (function_exists('xdebug_disable')) {
xdebug_disable();
}