loranger Posted August 29, 2018 Share Posted August 29, 2018 Hello ! I am now in charge of an e-commerce multi websites running prestashop 1.6.0.11. It runs for a decade, its source code is way too much customized and its database became really huuuge. I've been hired in order to unbloat this application, but I'm facing issue with the very first step : The development environment. It does not exists. Developers make modifications live, using FTP. I'd like to give them a local dev environment. I've setup a local web server which gets a fresh dump every night but each developer cannot use it as prestashop seems to require a canonical url for any shop, so my developers cannot use their brand new bob.myshop.local, dylan.myshop.local, kevin.myshop.local and so on… Another solution would be to dump the whole database for each developer, and alter ps_shop_url after every import but as I said, its really huge (its folder inside /var/lib/mysql/ weights 13GB) and we are 5 developers working on this application… Do you already have to deal with multi-developers environment ? Is there a way to bypass this prestashop url verification ? Thanks for your clues Link to comment Share on other sites More sharing options...
loranger Posted August 29, 2018 Author Share Posted August 29, 2018 Hooo yes ! That's what I did, but in order to finalize the whole development flow, I'd like to give each developer his own (locally reachable) dev environment, with a shared database (because of its actual size), but I can't figure out how to do… Link to comment Share on other sites More sharing options...
Knowband Plugins Posted August 30, 2018 Share Posted August 30, 2018 I would not recommend the shared database in the local environment. It will be the one-time activity to import the whole database on developer local machine (I think space will not be any issue on the local machine). You can keep one database which will be synced with live but developer should work on the local system. In case of share DB, One more problem that any developer can make changes in the DB structure & others might not be aware of the same. In the case of the individual local DB, each developer has to share their changes in the SQL format (ALTER, NEW DB tables) so that everyone should be aware of the changes. & Use GIT/SVN for the code sharing. Link to comment Share on other sites More sharing options...
loranger Posted September 20, 2018 Author Share Posted September 20, 2018 (edited) And finally I found a crappy solution : Inspired by the rewriter provided with the official prestashop docker image, I modified my docker's apache vhost and added the following line : php_value auto_prepend_file /docker_prepend.php From now, each webpage called from the prestashop hosted inside our docker dev environment is now preprended with these few php lines : <?php $pdo_dsn = sprintf('mysql:host=%s;dbname=%s', getenv('DB_SERVER'), getenv('MYSQL_DATABASE')); $DBHandler = new PDO($pdo_dsn, getenv('DB_USER_FRONT'), getenv('DB_PASSWD')); $DBStatement = $DBHandler->prepare("UPDATE `ps_shop_url` SET `domain` = :domain, `domain_ssl` = :domain WHERE `id_shop` = :shop_id AND `domain` != :domain;"); $DBStatement->execute([ 'domain' => $_SERVER['HTTP_HOST'], 'shop_id' => getenv('SHOP_ID'), ]); If the current request comes from an http_host which is not the same as the domain used by the targetted shop_id, the domain is rewritten just before prestashop is initiated. That's not perfect, but it definitely works and allows all of us to work on our local environments, sharing the same database, reaching any local server without taking care of the hostname. Edit : Oh and of course, this setup, as the prestashop codebase are now shared and deployed by using git. Edited September 20, 2018 by loranger Git to rule them all (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now