I'm trying to use phpDocumentor (for the first time, I have no idea what I'm doing).
Actually, I want to use it only with SublimeText 2 and this plugin. Can you guide me step by step what should I do to make it working?
Here's what I've done now: (I'm using Windows 7)
Downloaded phpDocumentor from here and placed it somewhere.
I've created system PATH's for phpdoc/bin (so phpdoc.bat can be executed by sublime plugin) and then also added system path to php (from WAMPserver installation)
When I try to use my plugin (or execute phpdoc inside console window) I get this error:
Could not open input file: \phpdoc.php
Run:
pear
it will set %PHP_PEAR_PHP_BIN% for you.
You will need to set the environmental path for "PHP_PEAR_BIN_DIR" to the directory where "phpdoc.php" is.
I have changed phpdoc.bat file to point to exactly location of phpdoc.php
#echo off
if "%PHPBIN%" == "" set PHPBIN=php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\wamp\bin\php\php5.3.10\phpdoc.php" %*
On my windows 7 system, I have my set up phpDocumentor (version 2.6.1) in wamp and my paths are like:
D:\Projects\wamp\www\phpDocumentor
D:\Projects\wamp\www\phpDocumentor\bin
Now what I did is I edited the phpdoc.bat file located at path:
D:\Projects\wamp\www\phpDocumentor\bin\phpdoc.bat
It contained code as shown below:
#echo off
if "%PHPBIN%" == "" set PHPBIN=php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "D:\Projects\wamp\www\phpDocumentor\bin\phpdoc" %*
So, I edited the last line "%PHPBIN%" "%PHP_PEAR_BIN_DIR%\phpdoc" %* with new code "%PHPBIN%" "phpdoc" %*. After phpdoc.bat looked like :
#echo off
if "%PHPBIN%" == "" set PHPBIN=php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "phpdoc" %*
Thereafter I again ran the below command in cmd:
D:\Projects\wamp\www\phpDocumentor\bin>phpdoc
And the output was like:
D:\Projects\wamp\www\phpDocumentor\bin>phpdoc
Collecting files .. OK
Initializing parser .. OK
Parsing files
[Exception]
No parsable files were found, did you specify any using the -f or -d parame
ter?
project:run [-t|--target[="..."]] [-f|--filename[="..."]] [-d|--directory[="..."
]] [--encoding[="..."]] [-e|--extensions[="..."]] [-i|--ignore[="..."]] [--ignor
e-tags[="..."]] [--hidden] [--ignore-symlinks] [-m|--markers[="..."]] [--title[=
"..."]] [--force] [--validate] [--visibility[="..."]] [--defaultpackagename[="..
."]] [--sourcecode] [-p|--progressbar] [--template[="..."]] [--parseprivate] [--
log[="..."]]
D:\Projects\wamp\www\phpDocumentor\bin>
So, the output showed that it worked successfully !!
PHP's include_path will need the path to the directory that contains that phpdoc.php file. Otherwise, none of the phpDocumentor code that uses require/include statements with relative paths will be able to find anything.
I just encountered this on Windows 7 having installed phpDocumentor2 via PEAR. I found that running:
phpdoc -d . -t docs
in an elevated command prompt did the trick - I suspect there's still some PATH issue on my machine that makes that the case, but having done all the default install steps for both PEAR and phpDocumentor it has proven the quickest workaround I've found.
I've got the same error message, the already made answers brought me to the right path.
As I don't use wamp/xampp or any of these programms, I thought: why don't run it directly with PHP?
I had already installed PHP7.0.x globally through WebPI.
Only php needs to be prefixed to the command, everything worked:
php .\phpDocumentor\bin\phpdoc -d .\src\ -t .\dst\
Related
I'm trying to run phpunit in my vagrant server in virtualbox(Ubuntu) for a school project, but I'm unable to.
I'm certain that my that phpunit is located in vendor/bin/phpunit and my test project is also in the right directory and everything is spelled correctly so I don't understand why I get this error.
I try to do:
vendor/bin/phpunit test/model/PDOGameModelTest.php
the error that I get is:
usr/bin/env: 'php\r': No such file or directory
Your file uses DOS file ending (CR+LF) and Ubuntu uses Unix one (LF). You have to convert your file with the command dos2unix :
Install it with :
sudo apt install dos2unix
Convert it with :
dos2unix test/model/PDOGameModelTest.php
Then :
vendor/bin/phpunit test/model/PDOGameModelTest.php
Edit : Another solution
awk '{ sub("\r$", ""); print }' test/model/PDOGameModelTest.php > test/model/PDOGameModelTest_converted.php
I have the same problem, but in my case it was a file
\vendor\bin\phpunit
it used DOS file ending (CR+LF) and Ubuntu uses Unix one (LF).
So I changed this file with NetBeans and the issue was fixed.
To change End Of File (EOF) in NetBeans just right click on the "file ending name" on a main window status bar.
I install And run drush as explained in this article:
My server is cloudlinux and cagefs.drupal7
Drush Use global php.ini File instead of drish.ini file and this issue makes some errors for open_basedir and disable_finctions functions.
when I run drush status command.give me following:
> The following restricted PHP modes have non-empty values:
> [error] open_basedir and disable_functions. This configuration is
> incompatible with drush. Please check your configuration settings in
> /opt/cpanel/ea-php56/root/etc/php.ini or in your drush.ini file; see
> examples/example.drush.ini for details. is_dir(): open_basedir
> restriction in effect. [warning]
> File(/usr/share/drush/commands) is not within the allowed path(s):
> (/home/:/usr/lib/php:/usr/local/lib/php:/usr/local/bin:/usr/share/drush:/usr/share/drush/commands:/etc:/tmp)
> preflight.inc:518 PHP configuration :
> /opt/cpanel/ea-php56/root/etc/php.ini
> /home/username/.drush/drush.ini PHP OS : Linux Drush script : /usr/local/bin/drush Drush
> version : 8.1.9 Drush temp directory : /tmp Drush
> configuration : Drush alias files :
So drush for me uses /opt/cpanel/ea-php56/root/etc/php.ini instead of /home/username/.drush/drush.ini
How Can I use drush.ini file instead of server php.ini file ?
I dont want edit global php.ini file for security reasone.
Have you tried adding EXPORT PHP_INI="/home/username/.drush/drush.ini" to your .bashrc file?
This is quite an old question, but I suspect that it is one that many people still puzzle over. Here is a solution that works for me (I'm using Ubuntu linux 18.04, but this should work for any unix system.)
Create a directory, e.g. /home/username/.drushrc
In this directory, create a file named 'php.ini', containing the php settings that you want to override. For example:
disable_functions=
open_basedir=
In your Drupal docroot directory, create a shell script, e.g. named 'mydrush', containing:
#!/bin/sh
PHP_INI_SCAN_DIR=:/home/username/.drushrc ./drush $*
The PHP_INI_SCAN_DIR environment variable specifies additional directories that php will look in to find .ini files when it starts up. The colon at the start of the assignment means that the directory you specify will be appended to the existing list of directories that php scans.
Make your shell script executable:
$ chmod +x mydrush
You can now call drush from your docroot directory using the command ./mydrush, for example:
$ ./mydrush status
Alternatively, you could set the environment variable PHP_INI_SCAN_DIR in your ~/.bashrc file. This would avoid the need for the 'mydrush' file, but it would change the php initialisation settings for every command-line invocation of php - not just when you're running Drush - and that may not be what you want. If you do change ~/.bashrc, then you need to open a new window for the changes to take effect.
I was using XAMPP, and added a XAMPP sub-directory to my PATH in ~/.bash_profile, and now for some reason all of a sudden /Applications/XAMPP is my home directory (e.g. when I type "cd ~" and do "ls", it only lists the contents of the XAMPP folder. And because of this, I can't find my ~/.bash_profile to revert the PATH back to normal. It seems to have disappeared. Any suggestions?
I'm not completely sure what causes you to end up in /Applications/XAMPP. But I can tell you a way to debug a login shell:
PS4='+ $BASH_SOURCE:$LINENO: ' bash -xlic ''
-x is for debug, -l is login, -i is interactive, and -c '' is a NOP command.
PS4 will be appended on each line printed by -x, and in our case it will print file and line number from where the code is executed.
I am not preferring using PEAR method, so I decided to use another way, However, I still cannot make a perfect .bat file to run in two situations.
I downloaded the phpunit.phar and the path I had added into PATH => C:\dev
e.g C:\dev\phpunit.phar
I also create a phpunit.bat file inside C:\dev\phpunit.bat, this allow me to run phpunit in any place.
This is the content of the phpunit.bat
#echo off
php c:\dev\phpunit.phar
I have run perfectly result when I am using the guard-phpunit. However, the problem is when I want to pass an argument / parameter to the phpunit it does not work.
E.g I got a testing file in C:\testing\CalculatorTest.php
When I run
C:\testing>phpunit C:\testing\CalculatorTest.php
or
C:\testing>phpunit CalculatorTest.php
It only output like php phpunit.phar, it does not take the argument.
It only work when I enter the command like this
C:\testing>php c:\dev\phpunit.phar CalculatorTest.php
I try to edit the phpunit.bat file to make it like below:
#echo off
set arg1=%1
:start
if "%1"=="" (goto :main)
REM without any argument
php C:\dev\phpunit.phar
goto :end
:main
php C:\dev\phpunit.phar %arg1%
:end
The above code will work in C:\testing>php c:\dev\phpunit.phar CalculatorTest.php, but when run in guard-phpunit it will keep prompting option --include-path requires an argument error.
Anyone know how to fix the .bat so it able to run in both situation?
Thank you so much!
I have created phpunit.bat file in same directory of the phpunit are instaled, for example B:\libs, containing:
#ECHO OFF
php "%~dp0phpunit.phar" %*
and in the windows PATH variable I added ;B:\libs:
Hold Win and press Pause.
Click Advanced System Settings.
Click Environment Variables.
Append ;B:\libs to the Path variable.
Restart Command Prompt.
After restart the terminal PHPunit works:
PS C:\Users\joridos> phpunit.bat --version
PHPUnit 4.1.3 by Sebastian Bergmann.
Use for phpunit.bat:
#echo off
php c:\dev\phpunit.phar %*
%* is replaced on execution by whatever was passed to phpunit.bat which means nothing if nothing was passed to phpunit.bat, or first + second + third + ... arguments exactly as specified on calling phpunit.bat.
I'm running php as a shell script.
(I am not sure if "shell script" is correct. The file starts with #!/usr/bin/php.)
This works great. But the MongoDB class doesn't get loaded as the correct php.ini file (having extension=mongo.so) is not used.
How do I make it use that php.ini file?
I already tried #!/usr/bin/php -c /usr/local/lib/php.ini
But I still get the same error - Fatal error: Class 'Mongo' not found
What can be done?
Try putting php.ini in the same folder as the php binary. It seems to look there first.
I know this because I used a very powerful and useful command-line program called strace to show me what's really going on behind my back
$ strace -o strace.log php --version
$ grep php.ini strace.log
Strace digs out kernel (system) calls that your program makes and dumps the output into the file specified after -o
It's easy to use grep to search for occurrences of php.ini in this log. It's pretty obvious looking at the following typical response to see what is going on.
open("/usr/bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/php.ini", O_RDONLY) = 3
lstat("/etc/php.ini", {st_mode=S_IFREG|0644, st_size=69105, ...}) = 0
Edit .bashrc located at your home directory and add this line:
alias php='php -c /path-to-custom/php.ini'
In this particular situation. I would
Check to see if the Mongo module is loaded (using extension_loaded() or class_exists())
If not loaded, try to load the Mongo module using dl()
If loading fails, display an error message so the admin can take care of it (STDERR or trigger_error()
Most distributions already ship different versions of php.ini for Web Servers and CLI. Are there other reasons to add another php.ini configuration for script XYZ (in addition to normal configuration)?
I came across this, because I had the same problem. Problem is there is more than one php.ini file used.
The one used by Apache is located in
/etc/php5/apache2/php.ini
This is the one that is modified to run MongoDB with extension=mongo.so.
However, when running a cron job, or from the terminal, it loads a different ini file. You can find this by using the line
grep php.ini strace.log
It is mentioned by thomas-peter.
The path where it displays '=3' is the php.ini file loaded when running the engine from the terminal, this ini file will need "extension=mongo.so" placed in it as well.
The other option is to use a small sh wrapper, something like this below in a myapp.sh file. Don’t forget to chmod +x on the script to run it.
#!/usr/bin/env sh
SOMEVAR='Yea Baby!'
export SOMEVAR
php -c /path/to/my/custom/php.ini /path/to/my/old_script.php
With the added bonus of being able to set or override environment variables pre-run.
This is a bit of a gotcha with PHP.
php -c /path/to/my/custom/php.ini works from the command line.
But try it in a script like this #!/usr/local/bin/php -c /path/to/my/custom/php.ini and your custom php won't load.
The Solution
Get rid of the space between -c and your path:
#!/usr/local/bin/php -c/path/to/my/custom/php.ini