Hi,
I googled a bit and found nothing on the subject. So, please excuse me if this topic has been raised before.
With today's release of a new version of EspoCRM I finally tried something I planned for quite a while. Installing EspoCRM as composer dependency. It worked fine for me so I would like to share my setup and ask for your opinion.
I have started with new `composer.json` with only requirement:
As espocrm/espocrm is not on the packagist I also had to add a repository:
yurikuzn/lightncandy was also required as EspoCRM uses custom fork.
So after running composer upgrade espocrm/espocrm was deployed to vendor.
Next I copied entire public/ directory from espocrm into my root.
Then I added post-install-cmd/post-update-cmd scripts to symlink my customizations to vendor and client/ dir back to my pub. It also runs `npm ci` and `grunt`.
Unfortunately it's a duplication of the same code. An alternative would be to put it into file but I prefer to keep it in composer.json.
Finally I created bootstrap.php with following content:
So now my repository contains only of `client/custom/`, `custom/, `public/`, `bootstrap.php` and composer lock and json. One more composer install run to build it all and everything works.
Benefits:
- next upgrade (or rollback) will be as easy as changing version in composer.json
- my repository only contains my modifications (less files, no temptation to hack the core)
What do you think?
I googled a bit and found nothing on the subject. So, please excuse me if this topic has been raised before.
With today's release of a new version of EspoCRM I finally tried something I planned for quite a while. Installing EspoCRM as composer dependency. It worked fine for me so I would like to share my setup and ask for your opinion.
I have started with new `composer.json` with only requirement:
Code:
"require": { "espocrm/espocrm": "8.3.6" }
Code:
"repositories": [ { "type": "vcs", "url": "git@github.com:espocrm/espocrm.git" }, { "type": "vcs", "url": "git@github.com:yurikuzn/lightncandy.git" } ]
So after running composer upgrade espocrm/espocrm was deployed to vendor.
Next I copied entire public/ directory from espocrm into my root.
Then I added post-install-cmd/post-update-cmd scripts to symlink my customizations to vendor and client/ dir back to my pub. It also runs `npm ci` and `grunt`.
Code:
"scripts": { "post-install-cmd": [ "mkdir -p data", "rm -fr vendor/espocrm/espocrm/data", "ln -s \"$(pwd)/data\" vendor/espocrm/espocrm/data", "rm -fr vendor/espocrm/espocrm/custom", "ln -s \"$(pwd)/custom\" vendor/espocrm/espocrm/custom", "rm -fr vendor/espocrm/espocrm/client/custom", "ln -s \"$(pwd)/client/custom\" vendor/espocrm/espocrm/client/custom", "if [ -d public/client ]; then rm -rf public/client; fi", "ln -s ../vendor/espocrm/espocrm/client public/client", "cd vendor/espocrm/espocrm && npm ci && grunt" ], "post-update-cmd": [ "mkdir -p data", "rm -fr vendor/espocrm/espocrm/data", "ln -s \"$(pwd)/data\" vendor/espocrm/espocrm/data", "rm -fr vendor/espocrm/espocrm/custom", "ln -s \"$(pwd)/custom\" vendor/espocrm/espocrm/custom", "rm -fr vendor/espocrm/espocrm/client/custom", "ln -s \"$(pwd)/client/custom\" vendor/espocrm/espocrm/client/custom", "if [ -d public/client ]; then rm -rf public/client; fi", "ln -s ../vendor/espocrm/espocrm/client public/client", "cd vendor/espocrm/espocrm && npm ci && grunt" ] }
Finally I created bootstrap.php with following content:
PHP Code:
<?php
declare(strict_types=1);
chdir(__DIR__ . '/vendor/espocrm/espocrm/');
set_include_path(__DIR__ . '/vendor/espocrm/espocrm/');
require_once 'vendor/autoload.php';
So now my repository contains only of `client/custom/`, `custom/, `public/`, `bootstrap.php` and composer lock and json. One more composer install run to build it all and everything works.
Benefits:
- next upgrade (or rollback) will be as easy as changing version in composer.json
- my repository only contains my modifications (less files, no temptation to hack the core)
What do you think?
Comment