Where to place downloaded PHP_CodeSniffer? - php

I want to download and install PHP CodeSniffer
On the website is mentioned that it can be installed manually. There is not mentioned, where I should place downloaded folder.
Is there any standard where I should place such PHP scripts from PEAR website?
I have installed PEAR into php but I cannot use "pear install" command ( I don't know why, either). For me it is more simplier solution to download pear manually.
(I am using WIndows 7)

You can add it to the php include path, or put it somewhere in your application. When you include or require the necessary files, you can specify an absolute or relative path to the file.
Example: if your app is at /my/app, consider putting the pear files in /my/app/lib/Pear, then include /my/app/lib/Pear/CodeSniffer.php

Related

How to upgrade php version on Windows 10

I'm trying to get my Laravel project to work. But when I use composer update it says the following:
This package requires php >=5.6.4 but your PHP version (5.5.12) does not satisfy that requirement.
I'm using WAMP which runs php version 7.0.4 this is also confirmed in the browser if I echo the php version. But when I use php -v in the console it shows that I'm using PHP version 5.5.12 (cli).
I've searched a bit around on google and I found out that it uses my windows PHP version instead of my webserver's version. But I couldn't find out how to update my PHP version on Windows.
My PATH contents are as shown in the following image
You can uninstall composer, and while re-installing it will ask you to point at your PHP directory which is going to be C:\wamp64\bin\php (usually) at that point you can choose which PHP version you would want to use. good luck.
This means you have yet another installation of PHP in your system. Check your Programs in Control Panel and remove such installation.
However, you can modify your PATH environment variable as well. Procedure
Just remove the path that points to any PHP installation directory.
Else, otherwise, if you are unsure about changing the PATH variable (which can lead to serious problems if not set well), you can just delete the directory that the PATH variable points to.... (I mean the PHP directory)
The totally better solution is to add the path of your PHP7 bin directory at the beginning of the PATH variable. You should also make available composer in this PHP7 bin directory.
Such as, replace the C:\php in your path with C:\wamp\bin\php7 or whatever the location of the PHP7 path is..
To update PHP on Windows 10.
You must put the folder of the new PHP version in the same folder as the old.
You rename the old folder or you delete it, prefer rename the old folder,
now you write in a terminal console
php - v
PHP automatically check for a new version
if you had installed before xampp/wampp and composer globally you might had added php to you environment path to call it where ever you want, and now you want that composer use the new xampp with php the you recently installed, so go to system>advance tab> environment variable> maybe in PATH then search if you have something like C:\xampp\php and edit to your new php location.
I had multiple versions off xampp for testing and composer globaly instaled for php 7.2

composer.phar always installs in /bin/php-5.5.8/

I am running on a Windows machine. I installed WT-NMP and I am trying to install composer.phar. No matter from what folder I run this
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
it always installs in the /bin/php-5.5.8/ instead of the /www/project folder where I want it. Because of this, whenever I try to run
composer update
I receive an error that it can't find the composer.json file (because the json file is in www/project but it is searching for it in /bin/php-5.5.8 instead). I tried everything that I could think of but I can't get it to work.
Any help is appreciated. Thanks!
You could try to find out the reason why it does what you don't like, but the installer script essentially only checks some settings of the PHP used before downloading the .phar file because debugging things inside the .phar is problematic, i.e. it would be a support nightmare if you'd simply download the pure .phar and try to run it if your PHP is unable to do so.
Long story short: You can simply copy or move the downloaded composer.phar to any location you like, and it will work.
you only need to specify where you want to install composer by changing PHP`s current working directory with chdir:
C:\WT-NMP\bin\php.bat -r "chdir('C:/WT-NMP/WWW'); eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
an odd solution to an odd installation method ;)

I downloaded aws.phar, but can't require it

I downloaded aws.phar from Official repository of the AWS SDK for PHP
I put the downloaded file named aws.phar in my my project.
require 'aws.phar';
It's under the same directory with my php file.
Anyone knows how to deal with it?
quite the same like : https://forums.aws.amazon.com/thread.jspa?messageID=399182&#399182
If your installed version of PHP includes Suhosin (a patch for the default installation of PHP to improve security), then it disallows phars by default.
Both Ubuntu and Debian distributions come with Suhosin enabled by default.
To allow it to work, you need to add an exception for phar.
Edit the file located at '/etc/php5/cli/conf.d/suhosin.ini':
suhosin.executor.include.whitelist = phar
I have soloved my problem with Composer.
At first, I thought Composer is for php default settings, but it is for the project that you created. You just need to create a file named "composer.json" in your project's directory. First navigate to the directory in the terminal, the rest steps are the same as show in aws/aws-sdk-php

how to install wkhtmltopdf on xampp?

i'd like to install wkhtmltopdf on my xampp system and use it under php.
any ideas how to do it - is there any tutorial? :/
i've run the wkhtmltox-0.10.0_rc2-installer.exe but it seems like it didn't change anything on my local xampp system.
thanks
The installer extracts the executable under C:\Program Files\wkhtmltopdf\ per default - or whatever you specified.
To use it from within PHP just supply the absolute path:
exec("c:/programs/wkhtmltopdf/wkhtmltopdf.exe www.site.com pdf.pdf");
Or move the .exe where it's easier accessible. (Should you care about making things simpler.)

What is the PHP PATH variable and how to I add to it?

Normally google is my friend for these kind of newbie problems, and I'm pretty proud of myself learning as I go without really needing to ask any questions in terms of PHP stuff, but this one's got me stumped. Trying to install a version of PEAR that supersedes my host's copy, which is hideously outdated. Apparently "pear's binary (bin) directory should be in your PATH variable." I don't know what that means or how to edit it, and supplementary to that, wether that will actually solve my problem of an outdated version of pear being on my root server. Any advice in either of these areas would be greatly welcomed, thank you.
Actually, they are talking about the OS's PATH environment variable, not PHP's include path (binaries [bin] are run by the OS, not parsed by PHP) Unfortunately, since you are in a shared hosting environment, you cannot change this environment variable in a permanent fashion. If you do have shell access though, you can modify your .profile file set the PATH variable.
You can use getenv() and putenv() to retrieve and set the PATH variable, but this will be reset on each script run.
That said, you do not need the PATH variables set to use PEAR. If you have a PEAR install on your development computer, you can upload the pear folder onto your host and modify the include_path at runtime to point to your own "install" using set_include_path()
$pearInstallPath = realpath('./pear/packages');
set_include_path('.' . PATH_SEPARATOR . $pearInstallPath);
The PATH variable that's being referred to doesn't actually have anything to do with PHP.
The PATH is the list of directories that your shell will look in to find a command you run on the command line. So, this is talking about making the shell find the right path when you run pear on the command line.
Assuming you're using bash, one way to change this is to add a line like
export PATH=/path/to/pear/bin:$PATH
to a .bash_profile or .profile file in your home directory.
Try this
getenv('PATH'); // for get PATH varibale
putenv('PATH=./'); // for set path variable
getenv, putenv

Categories