phpdoc web interface: Undefined offset: 1 in <PHPDOCDIR>\src\phpDocumentor\Console\Input\ArgvInput.php - phpdoc

I've installed phpdoc using the installer.php file, and when I open phpdoc.php from wamp (localhost/phpDocumentor/bin/phpdoc.php) I get this error:
Notice: Undefined offset: 1 in D:\Tools\Programming\WebsiteBuilding\WAMP\wamp2.2e\www\phpDocumentor\src\phpDocumentor\Console\Input\ArgvInput.php on line 52
I set register argc argv to true in my WAMP php - settings, but I still get this.
What am I doing wrong?
Snapshot of the error:

PHPDoc is intended for command line usage. The error you get means that you didn't provide an argument. This means you can't call PHPDoc via webserver, you can only view the generated docs.
A typical call to phpdoc under Windows looks like that (on the command line):
phpdoc.bat -d src -t docs
Where src is the directory that your sources are and docs the directory where the documentation should be generated.
For more instructions see the PHPDoc installer documentation.

Related

ejabberd module compilation error

I am new to ejabberd, trying to add new module for offline_message_posturl, on a Windows server. I couldn't find any blog post specifically for Windows other than the below. I am using ejabberd version 15.07.
I have been following this blog post:
http://jasonrowe.com/2011/12/30/ejabberd-offline-messages/
Right now I am not able to create a .beam file from the module file. I get this error:
> c(mod_http_offline).
mod_http_offline.erl:21: undefined macro 'INFO_MSG/2'
mod_http_offline.erl:27: undefined macro 'INFO_MSG/2'
mod_http_offline.erl:44: undefined macro 'INFO_MSG/2'
mod_http_offline.erl:11: function start/2 undefined
mod_http_offline.erl:11: function stop/1 undefined
mod_http_offline.erl:38: function post_offline_message/3 undefined
error
How can I fix this error?
The INFO_MSG macro used to be defined in the header file ejabberd.hrl, but it was moved to logger.hrl in ejabberd 13.06, which was released after that blog post was written. Include logger.hrl as well as ejabberd.hrl, and your file should compile:
-include("ejabberd.hrl").
-include("logger.hrl").
You are not pointing to ejabberd include .hrl file. Simplest approach is probably to add you module to ejabberd src directory and recompile everything.
Otherwise, you can compile your module with erlc using -I to point to ejabberd include dirs (use as many -I directive as needed). For example:
erlc -I ../ejabberd/include mod_http_offline.erl

Why does running phpunit not run vendor/bin/phpunit?

I am having a weird issue,
when I run
$ phpunit
I get
Fatal error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 185
Call Stack:
0.0009 231392 1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
0.0065 743872 2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
0.0066 744512 3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:106
1.1720 6818904 4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:155
1.4597 16188088 5. PHPUnit_TextUI_ResultPrinter->printResult() /vagrant/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:446
However, when I run
$ ./vendor/bin/phpunit
it works as expected and runs my tests.
Maybe I have another program or something that is using the phpunit alias or something?
How can I debug to find that out?
Any ideas?
Assume you had installed phpunit from composer.json of current Laravel App.
Run this:
vendor/phpunit/phpunit/phpunit
Because the global one might be incompatible version of phpunit. Which is called and execute in the current package.
On windows I have an incompatible version installed globally.
To workaround, create "phpunit.bat" in root of project with contents:
"vendor/bin/phpunit"
This takes precendece over the phpunit in the system path.
How did you configure adding /vendor/bin to path?
I have this in my ~/.bashrc file:
PATH="$PATH:/path/to/vendor/bin"
This adds /vendor/bin/ to the end of your path, so if there is any other executable called phpunit earlier in your path - in your case, the globally installed one - it will be called instead.
To fix this, add vendor/bin to the beginning of your path in ~/.bashrc:
PATH="/path/to/vendor/bin:$PATH"
Then log out and log in or run source ~/.bashrc, and the system should then find /vendor/bin/phpunit first when you runphpunit.
On Windows, you can set an enviroment variable in your project's root directory.
Type this in your console/terminal:
set phpunit=vendor/bin/phpunit
I had the same problem with Laravel and PhpStorm, and after i typed this in my PhpStorm terminal, the problem was solved.
I've just found about about doskeys for Windows. I think they are called aliases on Mac, but they allow you to create a command as an alias for another command.
This way, I can use:
doskey macroName=macroDefinition
which in my case is:
doskey p=.\vendor\bin\phpunit
which then means I can just use the command p from my project folder for phpunit - much quicker!
For example I can now use the command:
p --filter my_single_test tests/MyExampleTest.php

Custom templates with phpDocumentor 2

I've been trying to get a custom template to work with PHPDocumentor (2) without much luck. The documentation on their site is incomplete and I'm kind of stumped.
What I've done is downloaded a copy of a complete template and reference it in my command, like so:
php phpdoc.php
--template=/path/to/customtemplate/
-d /path/to/php/source/files
-t /path/to/generated/content/
The command runs fine: it generates the documentation correctly but appears to be ignoring the --template option - at least, any changes I make to the template files in the /customtemplate folder are ignored.
Anyone have any idea?
(Thanks in advance!)
Ben
Instead of declaring the template command on the CLI you might try changing your phpdoc.dist.xml configuration file so that it pulls the template name or path from there directly.

Zend OSX, and a "." added to context path

I downloaded and unpacked the latest version of Zend Framework, onto OSX (10.6) (am also running webserver with XAMPP, but I added the include_path change to both XAMPP and OSX path, but this is all command line so I dont think the php compiler is using the XAMPP install)
I try to create a project and get the following: (note that i am replacing part of the path with "----" just for the purpose of privacy)
sh-3.2# zf create project
testProject
Fatal error: Uncaught exception
'Zend_Exception' with message 'File "Zend/Tool/Project/Context/Zf/./AbstractClassFile.php" does not exist or class "Zend_Tool_Project_Context_Zf_._AbstractClassFile" was not found in the file' in /Volumes/----/----/z/library/Zend/Loader.php:99 Stack trace:
0 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(88):
Zend_Loader::loadClass('Zend_Tool_Proje...')
1 /Volumes/----/----/z/library/Zend/Tool/Project/Context/Repository.php(79):
Zend_Tool_Project_Context_Repository->addContextClass('Zend_Tool_Proje...')
2 /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php(87):
Zend_Tool_Project_Context_Repository->addContextsFromDirectory('/Volumes/----/...',
'Zend_Tool_Proje...')
3 /Volumes/----/----/z/library/Zend/Tool/Framework/Provider/Repository.php(187):
Zend_Tool_Project_Provider_Abstract->initialize()
4 /Volumes/----/----/z/library/Zend/Tool/Framework/Client/Abstract.php(128):
Zend_Tool_F in
/Volumes/----/----/z/library/Zend/Loader.php
on line 99 sh-3.2#
Note the period after "Context_Zf_"
I've narrowed it down to this block of code:
File: /Volumes/----/----/z/library/Zend/Tool/Project/Provider/Abstract.php
public function initialize()
{
// initialize the ZF Contexts (only once per php request)
if (!self::$_isInitialized) {
// load all base contexts ONCE
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Zf/', 'Zend_Tool_Project_Context_Zf_'
);
$contextRegistry->addContextsFromDirectory(
dirname(dirname(__FILE__)) . '/Context/Filesystem/', 'Zend_Tool_Project_Context_Filesystem_'
);
// determine if there are project specfic providers ONCE
Specifically "dirname(dirname(FILE))" is echoing as "."
if I wrap the block with an 'if (dirname(dirname(__FILE))!=".") { … } ', then I don't get that error, but I get another:
sh-3.2# zf create project testProject
An Error Has Occurred
Context by name applicationDirectory does not exist in the registry.
Zend Framework Command Line Console
Tool v1.11.3 Details for action
"Create" and provider "Project"
Project
zf create project path name-of-profile file-of-profile
I tested on my Mac and it works fine. Have you tried to restart you xampp server, I don't really know how it works as I use Apache & PHP already installed versions not a "AMP pack". Maybe it's a problem with the php.ini include_path which has not been reloaded.
It's clearly a problem with the path as it don't succeed to build the class name :
"Zend/Tool/Project/Context/Zf/./AbstractClassFile.php"
the dot should not appear here.
Can you share you PATH variable from the terminal and your include_path from your php.ini.
Sadly the solution was to install zend server community edition, and have that take care of everything for me. For anyone else on OSX going this route, check out: http://cmorrell.com/webdev/installing-zend-server-zend-framework-on-os-x-291
includes the steps for enabling CLI support.

phpDocumentor on legacy code

Can phpDocumentor be used to generate HTML docs for some legacy code that does not necessarily conform to its standard?
I'd like to generate some preliminary documentation for an old code tree and later on start improving my comments and add the appropriate # tags as I get fluent with phpDocumentor. I've never used this piece of software before and the examples I've found focus on how to write new code that conforms to its syntax and generate HTML file by file with the -f parameter.
I've installed latest phpDocumentor through the PEAR command line installer and tried this little *.bat file on Windows XP:
#echo off
phpdoc ^
--directory "\\server\project\trunk" ^
--target "C:\tests\project-doc"
... but this is all I get:
PHP Version 5.3.5
phpDocumentor version 1.4.3
Parsing configuration file phpDocumentor.ini...
(found in C:\Archivos de programa\PHP\pear\data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
directory: '' not found
I've also tried mapping the UNC path to a drive letter:
#echo off
phpdoc ^
--directory "I:\" ^
--target "C:\tests\project-doc"
... but:
PHP Version 5.3.5
phpDocumentor version 1.4.3
Parsing configuration file phpDocumentor.ini...
(found in C:\Archivos de programa\PHP\pear\data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
a target directory must be specified
try phpdoc -h
This error message is the same if I create "C:\tests\project-doc" before.
What's exactly wrong in my syntax?
phpDocumentor can indeed run against "undocumented" code. It builds its docs based on the code itself, and uses the docblocks as additional info (and additional organization, in the case of #package and #subpackage tags).
I'd suggest starting with phpDocumentor against your existing code, and work towards clearing out the warnings you see in the errors.html file that results -- this file is generated in the top level of your output docs, but there isn't any link to it from the output docs.
Once you have those cleared, you can start running phpDocumentor with the -ue argument (--undocumentedelements), which will add new warnings to errors.html, highlighting (in much greater detail) things that still need to be documented in docblocks.
Now, as for the issue you're having trying to run the program against code on a shared drive, I'm not sure what's wrong there. The script is clearly able to execute PHP and find the phpDocumentor code itself. You might try putting the arguments in the same line, rather than using the ^ as a line-feed escape character, and perhaps remove the quotes around the paths (since no spaces exist in the paths).
I think I've found what the issue is. The parameter parser is very picky and it doesn't like neither UNC paths nor bare root directories. If I replace this:
--directory "I:\"
... with this:
--directory "I:\."
... it finally starts running.
I suppose it's a bug. Their bug tracker doesn't seem to be public so I don't know if it's a known issue.

Resources