Disclaimer: am beginner.
I'm trying to build this certain PHP extension on Visual Studio Code 2017 in the Integrated Terminal, and I tried using the phpize command (there is an environment variable for the directory). It keeps outputting
C:\xampp\php\ext\php-geos
$ C:\xampp\php\php-src-php-7.2.6\win32\build\phpize
Input Error: Can not find script file "C:\xampp\php\php-src-php-7.2.6\win32\build\phpize.js".
Error generating configure script, configure script was not copied
even though it's right there. The file path is right. I checked the folder.
How can I fix this?
Found the problem: the .js file was actually a .js.in file. I solved the problem by changing the extension, but I guess another solution is to edit phpize and put .in where it is applicable.
Related
I am trying to serve a file index.php using the VSC extension five server, I know the PHP is valid. But when I hit the button to start the live server (or from the context menu in the file explorer) my browser only shows a PHP error page like this:
PHP ERROR
Could not find PHP executable
The page also suggests that I install XAMPP, but to my understanding that shouldn't be necessary because PHP 8.1.7-1ubuntu3.1 is already installed.
the command which php outputs /usr/bin/php, that file seems to be a shortcut pointing to /etc/alternatives/php which in turn points back to /usr/bin/php8.1
I tried adding these lines to settings.json:
"php.validate.executablePath": "/usr/bin/php",
"php.executablePath": "/usr/bin/php",
"phpserver.phpPath": "/usr/bin/php",
"fiveServer.php.executable": "/usr/bin/php",
I also created a fileserver.confg.js file in the root of my project with this line in it:
module.exports = {
php: "usr/bin/php"
};
I also tried using the path /usr/bin/php8.1 in both files, the only change was
that the error page now shows the path from fiveserver.config.js like this:
PHP ERROR
Could not find executable: "usr/bin/php"
There is a guide to working with PHP in this repository which seems to be related to my issue, but it might be written for a non-VSC-extension version of five-server, the command npx doesn't do anything on my machine; and I'm not familiar enough with php servers to adapt the instructions to my VSC setup. I'd be thankful for any ideas for things to try here.
A while ago, I successfully configured Atom to beautify my PHP using php-cs-fixer, but now I need to go through the same process on another Mac and can't remember exactly how I did it.
As a front-end dev, I'm not a PHP expert, but I understand that the Atom plugin is merely the middleman facilitating the actual fixing using php-cs-fixer, which, by default, it doesn't have access to. Once I installed the fixer, I had to add its location to my PATH variable. The confusing part is that I don't have the fixer installed via Atom (checked ~/.atom/packages) nor Homebrew (confirmed with brew list), however, the file is present in /usr/local/bin. If I move it, Atom returns the original error, so it's definitely using this file:
See https://github.com/FriendsOfPHP/PHP-CS-Fixer for program installation instructions.
Your program is properly installed if running 'which php-cs-fixer' in your Terminal returns an absolute path to the executable. If this does not work then you have not installed the program correctly and so Atom Beautify will not find the program. Atom Beautify requires that the program be found in your PATH environment variable.
Note that this is not an Atom Beautify issue if beautification does not work and the above command also does not work: this is expected behaviour, since you have not properly installed your program. Please properly setup the program and search through existing Atom Beautify issues before creating a new issue. See https://github.com/Glavin001/atom-beautify/search?q=php-cs-fixer&type=Issues for related Issues and https://github.com/Glavin001/atom-beautify/tree/master/docs for documentation. If you are still unable to resolve this issue on your own then please create a new issue and ask for help.
Hide Stack Trace
Error: Could not find 'php-cs-fixer'. The program may not be installed.
at PHPCSFixer.module.exports.Beautifier.commandNotFoundError (/Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:204:14)
at /Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:304:22
at tryCatcher (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:687:18)
at Async._drainQueue (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:148:10)
at Async.drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
at process._tickCallback (internal/process/next_tick.js:103:7)
which php-cs-fixer returns /usr/local/bin/php-cs-fixer and my PATH variable currently contains /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ourcore/.atom/packages/php-cs-fixer.
I guess my questions are, how is the fixer working if the PATH variable seems to be pointing to it in a different location, and how did it end up where it is? Does the location in my PATH matter at all, or does the Atom plugin know to look in /usr/local/bin? I just want to fully understand the entire process before repeating it.
EDIT: On further testing, I removed the Atom directory from my PATH and it didn't affect the plugin, so then I copied the file into the same directory onto the second Mac and it ran without issue, without needing to edit the PATH. Does the fixer file someone inform the OS?
Well first test "which php-cs-fixer" or "where php-cs-fixer" (depending on what os you're running) and if nothing is returned in the terminal then there actually is something wrong on the installation and the best thing to do is to manually install it.
Head to https://github.com/FriendsOfPHP/PHP-CS-Fixer and download it from there and follow the installation steps, after that it should all be good
I can't find a way to run php on Visual studio code, Does anyone know how?
Duplicate:
Yes it is but a little bit different from here.
Steps:
I followed below steps to configure php in VS Code.
Configure PHP linting in user settings
Install Php Debug extension in VSCode
Then configure php.ini file
Create a external php file in root folder
add <? echo "My First PHP site in VSCode."; ?> in external php file which I created now
In my index.html file I referenced my php file like:
Run my web server apache using xampp control panel
Build my project and run it on web browser it shows me nothing.
Also when I open dev tools of my chrome browser its shows me my php code of index file commented. why? I don't know.
Question:
What I am doing wrong in my above steps to configure php in vs code. Please explain me in easy steps so I can easily achieve my goal. Thanks in advance.
Looks like you in fact don't want to run PHP from Visual Code, but instead you're trying to get PHP to work at all.
add in external php file
which I created now
You're using short tags and that's ok, if your configuration allows it, however I would recommend using explicit PHP tags: <?php echo "My First PHP site in VSCode."; ?>
In my index.html file I referenced my php file like:
There's the problem. You're placing PHP code in a HTML file. PHP code in HTML files won't be (at least by default) executed. Change the filename from index.html to index.php.
That should do it.
I have begun learning PHP using an eBook. The following strange results are happening: Per the book I have created two simple PHP files. They are named phpinfo.php and hello.php. Both files show in the user root directory. Both files show when I use the ls command in my mac terminal.
When I try to run them in my browser only the first one runs. The second results in a 404 error, File Not Found. How is this possible? Could an internal file mistake cause this?
Thanks
Thank you all. It was suggested that it would be easier to delete everything including the app and start over. So I did and then downloaded MAMP. That worked.
Ive created a test page to test using Prince xml but this code doesn't seem to work.
index.php
require_once("prince.php");
$prince = new Prince('www1.must.edu.ph/tts/prince/Engine/bin/prince.exe');
$prince->setHTML(true);
$html = file_get_contents("reportHeader.html");
$ret = $prince->convert_string_to_file($html,'www1.must.edu.ph/tts/prince/Engine/bin/pink.pdf');
echo $html;
if($ret)
echo "converted";
else
echo "not";
whenever I access the page, there is no error.. it just displays the echoed $html and 'not'..
Problem 1:
I spotted the problem. You run PHP code in an .html ? Change the file extension to .php and re-upload to PHP-enabled hosting server & retry.
Problem 2:
The constructor does not set correctly. The constructor requires an absolute path on server, instead of an URL. The readme.html already mentioned this. It should look like:
$prince = new Prince('/usr/local/bin/prince');
In read me, it said:
On Windows, be sure to specify the path to the prince.exe file located
within the Engine\bin subfolder of the Prince installation.
Note: Most of the PHP-enabled hosting server are NOT Windows-based; even it's Windows-based, it won't allow you to execute .exe .
This happened to me, so I used SSH to access my server and realized that I did not have a font library installed. If you are using something like CentOS, then you will need to install a font library first. I found this helpful http://blog.whatgeek.com.pt/2011/11/10/install-core-fonts-centos-6/
Running Prince on a virtual box on my Mac using the YesLogic PHP wrapper and parsing the PHP files with a web browser. No PDF output, no errors reported by the wrapper.
The answers above didn't resolve the issue for me.
So I parsed the PHP files from the command line using 'php -f index.php' and it worked. Stupid mistake on my part - my PHP files simply didn't have the correct permissions.