Asked  7 Months ago    Answers:  5   Viewed   1.8k times

I tried to install composer via PHP command like said in getcomposer site,
But the bash throw an error:

 bash: php: command not found

So I did a search in google , and I came up with some answers, 1) to add php binary file path to $PATH variable
The problem is when I run:

 find / -name php -type f

I get this error:

find: ‘/run/user/1000/gvfs’: Permission denied

Even with sudo and as a root

2) To install tht php-cli package, so I run

 pacman -S php7-cli

But I get this error:

error: target not found: php7-cli

So what it isn't working for me?

I installed php via XAMPP installer and I', using manjaro

 Answers

51

Whenever you install XAMPP, you get all of the Apache, MySQL, PHP stack. The problem is, XAMPP won't link binaries to your PATH, because your could have another version of that software already installed.

Composer needs a PHP version available on your PATH, so the easier option is to link your already installed version of PHP.

I think you can find your PHP binary in /opt/lamp/bin so you can link it this way:

sudo ln -s /opt/llamp/bin/php /usr/bin/php

Hope it works!

If you want to double check your PHP binary location you can go to files then at the end you can find "other locations" click it and then go and check it.

Saturday, May 29, 2021
 
rypskar
answered 7 Months ago
91

If you have PHP installed as a command line tool (try issuing php to the terminal and see if it works), your shebang (#!) line needs to look like this:

#!/usr/bin/php

Put that at the top of your script, make it executable (chmod +x myscript.php), and make a Cron job to execute that script (same way you'd execute a bash script).

You can also use php myscript.php.

Wednesday, March 31, 2021
 
eek
answered 9 Months ago
eek
86

Use the following:

<?php
ob_implicit_flush(true);
ob_end_flush();

$cmd = "bash /path/to/test.sh";

$descriptorspec = array(
   0 => array("pipe", "r"),   // stdin is a pipe that the child will read from
   1 => array("pipe", "w"),   // stdout is a pipe that the child will write to
   2 => array("pipe", "w")    // stderr is a pipe that the child will write to
);


$process = proc_open($cmd, $descriptorspec, $pipes, realpath('./'), array());

if (is_resource($process)) {

    while ($s = fgets($pipes[1])) {
        print $s;

    }
}

?>

Change test.sh to:

#!/bin/bash
whoami
sleep 3
ls /

Explanation:

dmesg requires permissions. You need to grant webserver's user permissions for that. In my case apache2 is being run via www-data user.

ob_implicit_flush(true): Turns implicit flushing on. Implicit flushing will result in a flush operation after every output call, so that explicit calls to flush() will no longer be needed.

ob_end_flush(): Turns off output buffering, so we see results immediately.

Saturday, May 29, 2021
 
Axalix
answered 7 Months ago
83
sudo apt-get install php5-dev

phpize is a tool used to prepare a php module for building, so you'll need the dev package. There shouldn't be any problems, assuming you're using a packaged version of PHP anyway.

(Update - for more recent versions of Ubuntu try sudo apt-get install php-dev)

Saturday, May 29, 2021
 
Crontab
answered 7 Months ago
72

Certain spreadsheet file formats, such as OfficeOpenXML used as the default format by Excel 2007 and above, require ZipArchive. In most recent versions of PHP, ZipArchive is always available, but prior to PHP 5.3 it needed to be manually installed as a PHP extension.

As @briosheje says If you don't have ZipArchive installed/enabled for your PHP, then you can use

PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);

PCLZip is included in the PHPExcel distribution as an alternative to PHP's built-in ZipArchive class, though it is quite a bit slower. Enabling PCLZip allows you to work with zip-based spreadsheet formats even without ZipArchive.

However, when we first bundled PCLZip (originally in PHPExcel 1.7.6), it was only an option when writing zip-based formats, not when reading them. We changed that in PHPExcel 1.8.0, so enabling PCLZip now allows you to read zip-based formats as well as writing them.

The PHPEXcel Reader documentation details the different spreadsheet formats, and explains which ones are zip-based.

Monday, July 19, 2021
 
JackTheKnife
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 
Share