Symfony hack - Executing shell script to rewrite yaml files

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Symfony hack - Executing shell script to rewrite yaml files



I am using akeneo pim that uses symfony 3.4 to solve some clients desires. So this is my first time using symfony and I run into some problems. What I need to do is to create user interface, where user can add his own translations for the main menu. And those translations are coming from /translation/jsmessages.en.yml configuration file. So I have created a bundle, change the yaml file and everything is almost done. But now when I change yaml file I need to clear cache, dump the translations, run the webpack, otherwise the menu text change will not be visible. So I wanted to create shell script to do that. Something like this:


public function indexAction()

(new YmlReader())->readYmlFile();

exec('rm -rf ./web/bundles/* ./web/css/* ./web/js/*');
exec('rm -rf web/js/translations/*');
exec('php bin/console pim:install:assets --env=prod');
exec('php bin/console assets:install --symlink web');
exec('php bin/console oro:translation:dump');
exec('yarn run webpack');

return $this->render('PimcWhiteLabelBundle:Default:index.html.twig');



But this is not working, maybe because it executes the script as the www-data user, I don't know. And now I am trying to create command. Is there a good way of doing this through symfony, if someone knows, what is the best path of doing this in symfony. So I created a command, I just need direction how to approach this:


protected function execute(InputInterface $input, OutputInterface $output)

$argument = $input->getArgument('argument');

if ($input->getOption('option'))
// my exec commands


$output->writeln('Command result.');



Thank you for all your help.





You said "This is not working", what exactly? Can you provide any error message? output?
– Franck Gamess
Aug 6 at 8:18





Thank you for your reply, I added an answer, however I don't know if that is the best way to do this, but it works for now.
– user2450639
Aug 6 at 9:19




1 Answer
1



I solved this issue with exec command, it started to work for some reason :)


protected function execute(InputInterface $input, OutputInterface $output)

exec('rm -rf web/js/translations/*');
exec('php bin/console pim:install:assets --env=prod');
exec('php bin/console assets:install --symlink web');
exec('php bin/console oro:translation:dump');
exec('yarn run webpack');

$output->writeln('Translations dumped successfully.');





You can use also Symfony Process Component: symfony.com/doc/current/components/process.html
– Franck Gamess
Aug 6 at 9:28






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard