Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3924

Symfony 4: Command-Syntax to call Process Component

$
0
0

I have created a symfony command that can be executed successful from the shell using the following syntax:

php bin/console app:create-pdf 1 www.google.com

this command works! (the last two parameters are required for the command to process) Now I want to call this command inside my Controller using the Process Component https://symfony.com/doc/current/components/process.html, but I have trouble to pass the correct parameters to get things working, when I call the constructor.

 $phpBinaryFinder = new PhpExecutableFinder();
    $phpBinaryPath = $phpBinaryFinder->find();
    $projectRoot = $this->getParameter('kernel.project_dir');

    $process = new Process([$phpBinaryPath, $projectRoot . '/bin/console', 'app:create-pdf', $registration->getId(), $imageUrl]);
    $process->run();

My $phpBinaryPath is = "C:\xampp\php\php-cgi.exe" using xampp on windows. My $projectRoot is = "C:\Webprojekte2019\projectX"

This code snippet is "inspired" by this guide https://medium.com/@cedric.thibault/how-to-manage-asynchronous-process-in-php-with-symfony-4-2f0039d76fba


Viewing all articles
Browse latest Browse all 3924

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>