I have a Debian 8 distribution and am trying to get the tcpdf php library running for generating pdf documents. I notice that it is already installed as a package when searching for it in Synaptic Package Manager. It's version 6.0.093+dfsg-1 and its location is /usr/share/doc/php-tcpdf. I looked around online for instructions and tutorials for using the library in my php scripts but haven't found anything explicit and instructive. Neither do the official sites: https://tcpdf.org/ and https://github.com/tecnickcom/tc-lib-pdf offer any setup, installation, or integration documentation.
I downloaded the TCPDF-master.zip from https://github.com/tecnickcom/TCPDF , pasted it into my /var/www/html/ directory, but when I try running one of the examples, or the index.php file, the browser just gives me the following error:
The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500
The error.log file at /var/log/apache2 displays:
PHP Fatal error: Unknown: Failed opening required '/var/www/html/tcpdf/examples/example_001.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
I received the same errors even after installing PEAR and also when trying to run the fpdf library.
Please instruct me to follow the proper procedure on correctly using this library. Thanks.
First, install composer as described at http://www.bravo-kernel.com/2014/08/how-to-install-composer-on-debian/ . Make it globally available by running the following commands while logged in the terminal as user:
$ cd /usr/src
$ sudo apt-get install curl php5-cli
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
If the terminal responds with the following errors:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
a system restart might be needed due to a possibility of apt-get (or some GUI frontend to it) being halted while executing, leaving apt in a locked state.
Verify the installation:
$ composer --version
which should output:
Composer version 1.3.0 2016-12-24 00:47:03
or something similar.
Afterwards, navigate to the desired directory within terminal where you want to locally install the composer dependency. For instance: /var/www/html/ which is the web root on Debian. Input the command for installing the tcpdf php library:
composer require tecnickcom/tcpdf
as stated at https://packagist.org/packages/tecnickcom/tcpdf
All should now operate as intended.
Related
I'm trying to get access to rename_function in PHP, and for that I need PECL APD. I'm running Ubuntu 14.04 LTS.
I'm trying to run sudo pecl install apd, but I'm getting:
downloading apd-1.0.1.tgz ...
Starting to download apd-1.0.1.tgz (36,643 bytes)
..........done: 36,643 bytes
15 source files, building
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of
the module
If the command failed with 'phpize: not found' then you need to install php5-dev package. You can do it by running 'apt-get install php5-dev' as a root userERROR: `phpize' failed
Should I be running this command from a certain directory?
This time I tried it with verbose options turned on, in case there is a clue in the logs:
sudo /usr/bin/pecl -vvvvv install apd
Warning: file_exists(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1518
Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1528
Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1528
Downloading "http://pecl.php.net/get/apd-1.0.1.tgz"
downloading apd-1.0.1.tgz ...
Starting to download apd-1.0.1.tgz (36,643 bytes)
..........done: 36,643 bytes
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/LICENSE /usr/share/php/doc/apd/.tmpLICENSE
adding to transaction: chmod 664 /usr/share/php/doc/apd/.tmpLICENSE
adding to transaction: rename /usr/share/php/doc/apd/.tmpLICENSE /usr/share/php/doc/apd/LICENSE
adding to transaction: installed_as LICENSE /usr/share/php/doc/apd/LICENSE /usr/share/php/doc /apd
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/README /usr/share/php/doc/apd/.tmpREADME
adding to transaction: chmod 664 /usr/share/php/doc/apd/.tmpREADME
adding to transaction: rename /usr/share/php/doc/apd/.tmpREADME /usr/share/php/doc/apd/README
adding to transaction: installed_as README /usr/share/php/doc/apd/README /usr/share/php/doc /apd
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/pprofp /usr/bin/.tmppprofp
+ chmod +x /usr/bin/.tmppprofp
adding to transaction: chmod 775 /usr/bin/.tmppprofp
adding to transaction: rename /usr/bin/.tmppprofp /usr/bin/pprofp
adding to transaction: installed_as pprofp /usr/bin/pprofp /usr/bin /
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/pprof2calltree /usr/bin/.tmppprof2calltree
+ chmod +x /usr/bin/.tmppprof2calltree
adding to transaction: chmod 775 /usr/bin/.tmppprof2calltree
adding to transaction: rename /usr/bin/.tmppprof2calltree /usr/bin/pprof2calltree
adding to transaction: installed_as pprof2calltree /usr/bin/pprof2calltree /usr/bin /
15 source files, building
building in /tmp/pear/temp/pearf7LGca
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
If the command failed with 'phpize: not found' then you need to install php5-dev packageYou can do it by running 'apt-get install php5-dev' as a root userrolling back 12 file operations
+ rm /usr/share/php/doc/apd/.tmpLICENSE
+ rm /usr/share/php/doc/apd/.tmpREADME
+ rm /usr/bin/.tmppprofp
+ rm /usr/bin/.tmppprof2calltree
ERROR: `phpize' failed
Warning: unlink(/tmp/glibctestRdKE0K): No such file or directory in System.php on line 214
Warning: unlink(/tmp/pear/temp/pearf7LGca): No such file or directory in System.php on line 214
This will be a short summary of everything to is a precondition to run APD as a PHP profiler, I hope it will help your needs. This summary applies for PHP 5.6.2 APD 1.0.1 and might be incorrect for other versions.
First of all do not start it if you didn't ensure these two:
Deactivate Zend platform or any other PHP optimizer. In general you need to disable all Zend extensions.
Install a debugging enabled version of PHP (--enable-debug)
If you have a working PEAR setup you need to setup APD like in this article. Don't forget to try out distribution packages either. Otherwise APD's build as following:
Extract tarball.
Change directory in tarball.
Run <apache root>/bin/phpsize
Run ./configure (Add --with-php-config=<apache root>/bin/php-config if configure fails.)
Compile and install everything using
make
make install
Edit php.ini and add at least
zend_extension=/apd.so
apd.statement=1
apd.tracedir=/tmp/apd-traces
Create the output directory specified in php.ini
Now you'll need to restart Apache but before you do, check that the APD extension works fine. To do simply run PHP
/bin/php
No warning should be given if extension is loaded properly. If you get error message something like the "apd.so" extension couldn't be loaded there is a problem. Check if you compiled against the correct Apache/PHP version and using the same right now.
If PHP doesn't complain about anything enter:
<?php phpinfo(); ?>
and check for some lines about APD. If you find them you are done.
You'll also need some traces so to start tracing you need to your Apache to allow the PHP module to load APD. Next you'll need to identify the script to trace. Add the APD call at the top of the script:
apd_set_pprof_trace();
Then make some requests and remove the statement again to avoid causing further harm.
Now have a look at the trace directory. You should find files with a naming scheme of pprof[0-9]*.[0-9] here. Decode them using the pprofp tool from your APD source tarball. Example:
/bin/php /pprofp -u
Redirect stdout if necessary. Use -t instead of -u (summary output) to get calling trees. When you create traces with -t you get a summary output too, but it doesn't contain the per-call durations. I suggest to always create both a call tree and a summary trace.
Hope that helps, I recommend you hardly to read the link mentioned above.
EDIT:
The phpize command is meant to be run at the top level of an extension source dir (this source dir should contain a file name config.m4). See this for more info.
As per error:
If the command failed with phpize: not found then you need to install php5-dev package.
You can do it by running apt-get install php5-dev as a root user
I think you should install module development for PHP via:
sudo apt-get install php5-dev
This should provide you with phpize binary necessary to compile the Pecl extension sources. And make sure it's in your PATH.
I have these things:
the file http://api.odtu.lu/composer.phar
http://api.odtu.lu/phpinfo.php
ftp access
cPanel
Cron jobs on FreeBSD
PHP, Perl, CGI-BIN, Python, Curl.
How can I install Composer? (My aim is to install Restler)
Edit: I do not have SSH access.
This tutorial worked for me, resolving my issues with /usr/local/bin permission issues and php-cli (which composer requires, and may aliased differently on shared hosting).
First run these commands to download and install composer:
cd ~
mkdir bin
mkdir bin/composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar bin/composer
Determine the location of your php-cli (needed later on):
which php-cli
(If the above fails, use which php)
It should return the path, such as /usr/bin/php-cli, /usr/php/54/usr/bin/php-cli, etc.
edit ~/.bashrc and make sure this line is at the top, adding it if it is not:
[ -z "$PS1" ] && return
and then add this alias to the bottom (using the php-cli path that you determined earlier):
alias composer="/usr/bin/php-cli ~/bin/composer/composer.phar"
Finish with these commands:
source ~/.bashrc
composer --version
It depends on the host, but you probably simply can't (you can't on my shared host on Rackspace Cloud Sites - I asked them).
What you can do is set up an environment on your dev machine that roughly matches your shared host, and do all of your management through the command line locally. Then when everything is set (you've pulled in all the dependencies, updated, managed with git, etc.) you can "push" that to your shared host over (s)FTP.
I have successfully installed Composer (and Laravel) on my shared hosting with only FTP access:
Download and install PHPShell on a shared hosting
In PHPShell's config.php add a user and an alias:
php = "php -d suhosin.executor.include.whitelist=phar"
Log in to PHPShell and type: curl -sS https://getcomposer.org/installer | php
When successfully installed, run Composer: php composer.phar
You can do it that way:
Create a directory where you want to install composer (let's say /home/your_username/composer)
Go to this directory - cd /home/your_username/composer
Then run the following command:
php -r "readfile('https://getcomposer.org/installer');" | php
After that if you want to run composer, you can do it this way (in this caseyou must be in the composer's dir): php composer.phar
As a next step, you can do this:
alias composer="/home/your_username/composer/composer.phar".
And run commands like you do it normally: $ composer install
Hope that helps
I was able to install composer on HostGator's shared hosting. Logged in to SSH with Putty, right after login you should be in your home directory, which is usually /home/username, where username is your username obviously. Then ran the curl command posted by #niutech above. This downloaded the composer to my home directory and it's now accessible and working well.
SIMPLE SOLUTION (tested on Red Hat):
run command: curl -sS https://getcomposer.org/installer | php
to use it: php composer.phar
SYSTEM WIDE SOLLUTION (tested on Red Hat):
run command: mv composer.phar /usr/local/bin/composer
to use it: composer update
now you can call composer from any directory.
Source: http://www.agix.com.au/install-composer-on-centosredhat/
Most of the time you can't - depending on the host. You can contact the support team where your hosting is subscribed to, and if they confirmed that it is really not allowed, you can just set up the composer on your dev machine, and commit and push all dependencies to your live server using Git or whatever you prefer.
PHP API using: https://github.com/sandeepshetty/shopify_api
I have PHP 5.3.27 installed
I installed Composer (by going to
the website and using their install.exe)
It mentions that
"This will download shopify_api into the
vendor/sandeepshetty/shopify_api directory."
But I do not see the folders or files anywhere on the computer.
The plugin author is saying that if you download Composer with the instructions he provided (via Terminal), then Composer will autoload those files for you. Unfortunately, though easier, simply going to the source URL for the Composer tool won't do that for you.
First, make sure you have created the composer.json file and stored it in your project directory. Then, log into your server or system via the command line (Terminal for Mac OS, Putty for Windows). Cd into your project directory, and install by entering these commands:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install
I can't figure out how to run zf.php (Zend Framework 2 Tool) when bootstrapped with composer.
First I bootstrap composer and zftool according to the documentation:
$ mkdir tmp && cd tmp
$ curl -s https://getcomposer.org/installer | php
$ ./composer.phar require zendframework/zftool:dev-master
This works fine so far.
But when I try to run zf.php, I get errors:
$ vendor/zendframework/zftool/zf.php
PHP Warning: require_once(/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php): failed to open stream: No such file or directory in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
Warning: require_once(/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php): failed to open stream: No such file or directory in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
PHP Fatal error: require_once(): Failed opening required '/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php' (include_path='.:/opt/local/lib/php') in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
Fatal error: require_once(): Failed opening required '/Users/seb/tmp/vendor/zendframework/zftool/vendor/autoload.php' (include_path='.:/opt/local/lib/php') in /Users/seb/tmp/vendor/zendframework/zftool/zf.php on line 13
What am I doing wrong? I'm using PHP 5.3.21 on Mac.
I also tested it on my Debian VServer with PHP 5.4, same error :(
You should copy zf.php into your root directory and run it from there.
$ mkdir tmp && cd tmp
$ curl -s https://getcomposer.org/installer | php
$ ./composer.phar require zendframework/zftool:dev-master
$ cp vendor/zendframework/zftool/zf.php .
$ php zf.php
Install Composer.phar locally
If you do not have the composer globally installed on your machine, you can install it locally in the project.
Installing Composer locally is a matter of just running the installer in your project directory (https://getcomposer.org/doc/00-intro.md).
curl -sS https://getcomposer.org/installer | php
Note: If the above fails for some reason, you can download the installer with php instead:
php -r "readfile('https://getcomposer.org/installer');" | php
Install ZF2
git clone git://github.com/zendframework/ZendSkeletonApplication.git --recursive
cd ZendSkeletonApplication
php composer.phar self-update
php composer.phar install
Install ZFTools (Installation using Composer)
php composer.phar require zendframework/zftool:dev-master
php composer.phar install
Create a symbolic link
zf.php (Zend Tool) will be installed in the vendor/bin folder. You may run it with php vendor/bin/zf.php.
ln -s vendor/zendframework/zftool/zf2.bat zftools
chmod +x zftools
./zftools
In this case, I prefer symbolic link, for updating the zftools repository, I do not need to copy the file again.
Without installation, using the PHAR file
Another alternative to using the ZF tools, without creating scripts or aliases, and download the PHAR format.
wget https://packages.zendframework.com/zftool.phar --no-check-certificate
php zftool.phar version
ZFTool - Zend Framework 2 command line Tool
The ZFTool is using Zend Framework 2.2.4
Or you can download zftool.phar and use it.
Note 1:The #akond response is very good, I'm just presenting an alternative answer I like to use.
Note 2: This example was done on a windows machine using cygwin.
Good tutorial installation (ZF2 and ZF3)
Getting started: A skeleton application
Ref:
Zend Framework Tool (ZFTool)
I've already installed the RabbitMQ on my server and everything is working fine with it. I already tried to send and receive queued messages with a Java client and everything went perfect.
Now I need to install a PHP RabbitMQ client because I want to communicate a Java program with a PHP webpage, but this time I'm not beign so lucky.
I already followed the steps of the official webpage for this installation, specifically these steps:
# Download the rabbitmq-c library
hg clone http://hg.rabbitmq.com/rabbitmq-c/rev/3c549bb09c16 rabbitmq-c
cd rabbitmq-c
# Add the codegen requirement
hg clone http://hg.rabbitmq.com/rabbitmq-codegen/rev/f8b34141e6cb codegen
# Configure, compile and install
autoreconf -i && ./configure && make && sudo make install
And actually on the console I can see that it was "installed" without any problems. But when I try to open any AMQP Connection I get this error:
Fatal error: Class 'AMQPConnection' not found
Actually if I use the phpinfo(); command I can't see anything related to an AMQP module (like in this question). So I think that it may be a problem with the installation but I tried reinstalling it two times and it keeps saying that everything went well.
Have anyone crossed with this problem too?
Solved it..
The module wasn't being loaded in the right php.ini file. Just added extension=amqp.so at the end of the right php.ini file and restarted Apache.