I followed the directions on the readme file but I didn't get any errors nor any output or anything written to the log file.
so, what is the right way of converting and HTML file to PDF with prince, thank you in advance.
ini_set('display_errors', '1');
error_reporting(-1);
require 'prince.php';
$exepath='/Users/agk/Desktop/prince/bin/prince';
$prince= new Prince($exepath);
if(!$prince) die("Prince instantiation failed");
$prince->setHTML(TRUE);
$prince->setLog('prince.log');
$xmlPath='/Applications/MAMP/htdocs/test/newhtml.html';
$msgs= array();
$convert=$prince->convert_file($xmlPath, $msgs);
if(!$convert)
{
echo 'nothing converted';
var_dump($msgs);
}
I notice you are using MAMP - and this is where I hit the same issue - and here's how I fixed it.
I managed to find an answer elsewhere on SO relating to running shell commands via PHP on MAMP, so will share this.
The problem is that the DYLD_LIBRARY_PATH is set in MAMP, and the shell/shell_exec command in PHP is looking elsewhere.
As explained in the original post, this might not be the best fix but it has me up and running for now - and the alternative suggestions there didn't work for me.
So, try this:
Open the /Applications/MAMP/Library/bin/envvars file and comment the following lines as below:
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
then restart Apache
It might mess up other MAMP settings, but I can live with that for now, as I need this to work locally on my Mac for testing before I load it all on a live Linux server.
Hope this helps.
Related
I am taking a Udemy class for WordPress. I can create a function just fine. However, when I started using the variables and array it will not work. I get a message saying there is no "php.validate.executablePath" and "php.executablePath" via settings.json.
So I downloaded the zip file of PHP 7.3 (7.3.17) VC15 x64 Non Thread Safe and extracted it to C:\php7.3. I then added the path to the settings.json: "php.validate.executablePath": "C:\php7.3\php.exe", "php.executablePath": "C:\php7.3\php.exe"
I then restarted my VSC and nothing happened. I even restarted my computer. The notification never popped up again but I still cannot run PHP. In replace of the \, I used one \, then one /, then two / but it did not change anything. I looked this issue up - found others who had the same issue - and have not found anything that has worked for me so far.
I also tried downloading the xampp but there was an issue at port 443. That's when I downloaded the PHP file directly and uninstalled xampp.
EDIT: Do I have to have something like xampp or wamp to execute the PHP? If so, I would just need to figure out how to fix that error.
Here is a screenshot of the code I used: http://prntscr.com/sahb1f
Here is a screenshot of the settings.json: http://prntscr.com/sahbk0
I am on Windows 10 x64. A tool extension for VSC costs money, which I do not want to spend.
Any help?
Thanks!
You are missing the echo in front of the $names[0] array element access.
change your line to this <p>Hi, my name is <?php echo $names[0]; ?></p> and it should work however your error to do with executablePath might be because of something else.
I installed the Couchbase Server and its PHP SDK through brew install libcouchbase on Mac. The server admin console is running/working fine on http://127.0.0.1:8091/. I added a hello.php file with the below code in /Library/WebServer/Documents/hello.php.
<?php
$cb = #new Couchbase("http://127.0.0.1:8091/",'username','password');
if($cb->getResultCode() != COUCHBASE_SUCCESS){
throw Exception('Cannot connect to couchbase!');
} else {
echo "Hello World!";
}
When I go to http://127.0.0.1:8091/hello.php, I get an error saying Not found.. What is the problem?
When I go to http://127.0.0.1:8091/hello.php, I get the below error
Not found.. What is the problem?
You are going to the wrong port. Port 8091 is the Couchbase Server Console interface. It looks like you are trying to deploy your hello.php script using the Apache server shipped with OS X which uses the default http port (80). The script is also located in the wrong folder. I believe /Library/WebServer/Documents/ is for static content only.
Given the problem you have ran into it make me suspect that you are trying to learn too many new things at once. You should try running the script outside of a Apache first and get it working there.
php hello.php
It is also worth pointing out that you are using the older 1.X version of the Couchbase PHP SDK, you will want to use the new 2.X version.
I assume you've anonymized the code above, but be sure in place of where you have 'username' you have the bucket name and similarly for the bucket password or empty string if no password. Also, check the docs as the connect string you're using is not necessarily the preferred..
Note for debugging these kinds of things you can set LCB_LOGLEVEL to a higher level as mentioned in the documentation. The way you set an envvar varies based on how you're deploying PHP, but you can easily just test it at the command line.
I am using ZendFramwork1, my local sever php 5.4. and with MongoDB .I have use function Zend_Pdf to draw PDF in my project. it's run well in my local server. but when i put code to sever that have same version PHP. Everything module is okay but for function print data to pdf is errors . I got message like PDF error: Can not open 'data/reports/myfile.pdf' file for writing. . Any one can help me . what's different between my local server and real sever ?
I am looking to see your reply soon.
thank
First off, chmod 777 is a hack and shouldn't really be used. If you're using apache, you are better off chown'ing the folder to the correct user.
I installed the SublimeLinter plugin for Sumblime-text-2 in Ubuntu 12.04.
The PHP linting does not work. After an exhaustive search on the internet, I found out that I have to give the path to PHP in the sublimeLinter settings as below:
"sublimelinter_executable_map":
{
"php":"/usr/share/php"
},
This was the path in the line include_path I found in the phpInfo(). But it does not work.
I tried escaping the special characters, and other paths like /usr/share/php5, /usr/lib/php5, but nothing seems to work.
Can anyone help with the correct configuration, so that I can get the linter functionality to work?
Note: There has been a previous unanswered question here. I thought maybe I should ask it again, in a little more detail.
UPDATE: The original question has been answered and solves this question as well.
1- Install node.js. Which, by the way, is pretty darn awesome in its own right.
2- Open up Sublime Text, and close all open files.
3- Head to Preferences->Package Settings->SublimeLinter->Settings – User (it will be empty if you haven’t messed with it before), and insert the following:
{
"sublimelinter_executable_map":
{
"javascript":"C:/Program Files/nodejs/node.exe",
"css":"C:/Program Files/nodejs/node.exe",
"php":"C:/wamp/bin/php/php5.4.3/php.exe"
}
}
This is also where you’d put paths to, say, php for linting. Make sure you get the path to node correct – this is the default location on a Windows 7 install. Save the file, close the file, and restart Sublime Text.
sources: http://fuzzytolerance.info/blog/2012/05/14/2012-05-15-getting-sublimelinter-running-on-windows/
For ubuntu system type in terminal:
which php
and use the result in your php path (Preferences->Package Settings->SublimeLinter->Settings -User).
In my case it's:
{
"sublimelinter_executable_map": {
"php": "/usr/bin/php"
}
}
php.exe file path on Windows 7 didn't do the trick for me, while
php-win.exe did:
{
"sublimelinter_executable_map":
{
"php":"C:/php/php-win.exe"
}
}
php-win.exe file path on Windows 7 didn't do the trick for me!!!
"sublimelinter_executable_map":
{
"javascript":"C:/Program Files/nodejs/node.exe",
"php":"C:/xampp/php/php-win.exe",
"css":"C:/Program Files/nodejs/node.exe"
}
I am using wamp server 2.0 on windows XP with PHP version 5.2.5 when I am using the following code
<?
echo "hai";
?>
I am not getting the output. But when I am using
<?php
echo "hai";
?>
Got the result.If I am using the first one in Linux server I got the output.One of my large project like the first one in all php pages.I want to configure with wamp.SO if first coding needs to work what can I do?
My first guess is your php.ini isn't configured for this. The parameter short_open_tag is responsible for it.
Edit your php.ini, search the following parameter and activate it (or add it when its missing there):
short_open_tag = On
More details are in the php-manual.
i'm not using wamp now, maybe you can test solution from http://www.wampserver.com/phorum/read.php?2,50473,50474#msg-50474.
Wish this can help you. :)