I'm trying everything I can to get phpdocumentor to allow me to use the DocBook tutorial format to supplement the documentation it creates:
I am using Eclipse
I've installed phpDocumentor via PEAR on an OSX machine
I can run and auto generate code from my php classes
It won't format Tutorials - I can't find a solution
I've tried moving the .pkg example file all over the file structure, in subfolders using a similar name to the package that is being referenced within the code .. I'm really at a loss - if someone could explain WHERE they place the .pkg and other DocBook files in relation to the code they are documenting and how they trigger phpdoc to format it I would appreciate it, I'm using this at the moment:
phpdoc -o HTML:Smarty:HandS
-d "/path/to/code/classes/", "/path/to/code/docs/tutorials/"
-t /path/to/output
I didn't expect to be answering my own question, but after 2 days of mind bending pain and a weekend to experiment it seems this is the problem:
The tutorial and my examples should work, but there seems to be a minor flaw in the way phpdoc interprets the switch values. Here is what I've been using:
phpdoc -o HTML:Smarty:HandS
-d "/path/to/code/classes/", "/path/to/code/docs/tutorials/"
-t /path/to/output
However if you use the following:
phpdoc -o HTML:Smarty:HandS
-d /path/to/code/classes/, /path/to/code/docs/tutorials/
-t /path/to/output
It will correctly format your tutorials and extending docs, all I did was drop the double quotes surrounding the directory paths. Single quotes don't work at all - as phpdoc itself wraps the directories in double quotes if there are no spaces ... this does seem like a bug with phpdoc, and the same behaviour occurred with the web based interface, so its an internal issue. my original attempt should have worked but didn't I will contact the developers and bring it to their attention.
Problem solved.
Have you read this?
It suggest the following path scheme: tutorials/package/package.pkg where package is the name of your package, did you do it this way?
I was experiencing the same issue using an .ini for configuration, but with me the problem was that I put a space in between the comma and the directory, which resulted in the directory not being 'linked' to the -d parameter.
Not working:
directory = {$lib}/Question,{$lib}/Error, {$path}/docs/tutorials
Working:
directory = {$lib}/Question,{$lib}/Error,{$path}/docs/tutorials
Hope this solves the problem for someone else!
Yes, your usage of the double quotes probably threw off phpDocumentor's internal runtime argument parsing, causing -d /path/to/code/classes to be one arg/value pair, without including /path/to/code/docs/tutorials as an additional directory value.
Typically, I've seen two other issues around tutorials not being created. One, the tutorial directory isn't what phpDocumentor expects. Two, no actual PHP code files are included in the execution. I remember adding verbiage to the manual specifically for these two scenarios.
Related
I've taken over a code base of a Symfony 4.4-project, with a couple of extra bundles installed (Sonata being the biggest one). When I write: php bin/console list, then it prints the source code for several of the classes in the src/Admin-directory. And I can't figure out why.
I've searched the code for print, var_dump and dump, but can't figure out where this is.
I'm not familiar enough with Symfony, to go through the code 'from the top', adding my own dump-statements, narrowing it down, where this code is coming from.
Had this been Laravel, then I would have started in the routes, then moved on to maybe the kernel or middleware, then to the controlles - and in the end the views.
Does anyone have a good suggestion on which files to add dump-statements to, to see where this code is coming from?
... Or if anyone else has a good idea on how to find this code, then I'm all ears.
Is it maybe an entire namespace that is printed? And can one even do that?! Hmm...
This is what it looks like:
You'll get this behavior if the code you've inherited uses short open tags <? but your personal dev environment's PHP installation has them disabled. Run php --ini to find where your ini file is and then edit that to change from this:
short_open_tag = Off
To this:
short_open_tag = On
Alternatively, you could edit all the source files and change the short open tags <? to long open tags <?php.
This used to work, but it stopped working recently. I don't think anything changed in my settings, but I have poured over them for a couple hours now just to make sure. I have checked all over google and SO too. Please pay attention to the details before claiming "this was answered over here..." Thanks. :)
Assumptions and Requirements
Assume we have two files:
<project_root>/index.php
<project_root>/folder/file.php
Assume our project root is /home/me/project.
We want to include file.php from index.php. We expect PhpStorm to be able to resolve the file path and allow us to do nifty IDE things like "Go To Declaration."
What works
require 'folder/file.php';
require '/home/me/project/folder/file.php';
$root = '/home/me/project/';
require $root.'folder/file.php';
What No Longer Works
define('ROOT_DIR', "/home/me/project/");
require ROOT_DIR.'folder/file.php';
PhpStorm does recognize the value of ROOT_DIR when I mouseover, but it highlights home and says something like: Path '"/home/me...folder/file.php' not found
Why Use a Constant Anyway?
To keep this simple, I've left out details that are not necessary to illustrate the problem. The primary thing I'd like to address is why this used to work but no longer does, and/or how can I make it work again.
Sorry, can't help. What are you really trying to do?
Here are the details I left out. If we can't solve the primary issue, perhaps we can find a good work around.
I'm working with an existing codebase. Most files require a config.php file that defines root_dir() for getting the web/project root. PhpStorm wasn't resolving those paths (understandably so), so I created a constant to takes it's place. That makes more sense anyway.
In today's battle, I discovered that you can do this:
/** #define "root_dir()" "/home/me/project/" */
// or
/** #define "ROOT_DIR" "/home/me/project/" */
If you put that anywhere in the file then PhpStorm is able to resolve all the includes/requires in that file. BUT, it only works in that file, even if you try to include/require it in another file. You'd have to do this to EVERY file to get it working everywhere. Nope. Nuh-uh. No thank you. I need to reference the absolute path to the project/web root in a way that PhpStorm will recognize across the whole project.
#LazyOne answered this in the comments. This is a bug in the latest release, and it's being tracked here: https://youtrack.jetbrains.com/issue/WI-31754
Until this gets patched I've created this work around:
Using Keyboard Maestro, I created a hotkey that will paste the #define comment at the top of the file and return the cursor to its original position. Download the macro here. Import that and edit the text.
Edit: You may actually need to edit the file in a regular text editor. One of the file paths may need to be changed to work on your system.
Note: I'm using a modified version of the Mac Eclipse keyboard layout in PHPStorm. I'm not sure that will matter.
Also, be aware that many of your "changed files" will simply have this mapping at the top of the file, and this mapping may not be correct for you teammates. I'm simply excluding those changes from my commits.
I have Aspell successfully installed and have compiled PHP with Pspell, and everything seems to be working fine.
The only thing I am unable to do, is create a list of "ignore" words, or a personal dictionary, however you want to refer to it.
I've tried the steps outlined here and here but neither had any effect.
As described at the above link and on the Aspell documentation, I tried creating a personal dictionary as outlined in the manual:
personal_ws-1.1 en 0
Rubiflex
quasirhombicosidodecahedron
I placed this in the aspell directory, my home directory, the root directory, and it was never picked up. The Aspell documentation never actually says where it should live or how to otherwise load it.
The other reference is to creating an individual word list:
Create a txt file with the words that you'd like to add to the dictionary, where each word is on a separate line then run the following command:
aspell --lang=en create master ./custom.rws < test.txt
This will create a file called custom.rws that will contain the aspell encoded word(s) for the dictionary. You can name the file
anything you want as long as the extension is .rws. Now to add this
to the dictionary move the custom.rws file to the dictionary location
which is /usr/lib/aspell by running the following command:
cp custom.rws /usr/lib/aspell/
To finish adding it to the dictionary change into the dictionary directory by running the following:
cd /usr/lib/aspell/
then edit the following file: nano en_US.multi
and add the following line:
add custom.rws
Neither of these methods seemed to work and I cannot find any clear examples of how to properly add a dictionary or word list. These were the two most promising methods I was able to find and neither worked. Does anyone know how I can get Aspell to use a personal dictionary file I create?
Thank you for your time.
EDIT:
The steps outlined here worked for me. The are much like the ones outlined here except that the latter refers to "en_US.multi" where the former refers to "en.multi". After adding the custom list to en.multi (as opposed to en_US.multi), it was working as expected.
For my latest work onto the Perl's Text::Aspell module and code to determine the mother language of a Web visitor querying a company's search engine, I came across some of the pitfalls you describe (personal dictionary not implemented in Aspell6). However I worked it around using the 'extra-dicts' notion, one for each possible language.
I also had to workaround the fact that Aspell owns no dictionary for the Arabic, Hebrew, Japanese, Chinese and Korean languages. These languages are dealt with specifically.
You may view the full latest Perl's and bash codes for Linux and Windows running Windows/MinGW at http://vouters.dyndns.org/tima/Linux-Windows-Perl-Aspell-Determining_the_country_of_a_Web_query.html. You may use the URL links in the REFERENCES section of the document to adjust some of the Perl's code notions to PHP.
I was able to add a personal dictonary using option --add-extra-dicts to aspell call
aspell -c --add-extra-dicts=./custom.rws my_text_to_spell_check.txt
custom.rws has been created as depicted by OP:
aspell --encoding=UTF-8 --lang=<lang> create master ./custom.rws < test.txt
And remember to add --encoding opton to match the correct encoding for your source file.
I Hope this can help someone!
Using the aspell version below with Cygwin:
International Ispell Version 3.1.20 (but really Aspell 0.60.6.1)
it was looking for a personal dictionary named .aspell.en.pws in my home directory, regardless of what I specified on the command line with the --personal option. I was able to place a symbolic link named .aspell.en.pws in my home directory and let it point to a different location on my file system. I had to create the file first and add the required header before aspell would start adding to my personal dictionary.
In short, you can do this:
echo "personal_ws-1.1 en" > ~/my/file/location.pws
ln -s ~/my/file/location.pws ~/.aspell.en.pws
Let's say i have this php function called from multiple php files
do_something($var);
How can i find the files from which the function is called?
later edit: i want to do this on windows
At least some IDE's have a means of searching through your current project for all instances of certain variables, function calls, etc. If you are using an IDE, check its help.
If you are using a *nix system, you can use grep to search:
grep do_something *.php'
The above will search your current working directory for the text 'do_something' in all files ending with the '.php' extension. You can expand this to search all subdirectories of the current directory using the find command:
find . -name "*.php" -exec grep do_something {} \;
Use 'man grep' and 'man find' from your *nix command line to learn more.
If you are on Windows, I believe the find command can do similar things, I am not as familiar with it, but the basic syntax should look something like:
find "do_something" *.php
Three ways to do this:
Use a sensible directory structure and application design. If you're following OOD and have a clearly laid out directory structure, then it should be very easy to find the declaration for any class and its methods. If the method was declared in a parent class, you just scan up the inheritance tree. If, OTOH, you're writing spaghetti code and using tons of global functions, well... you've got bigger problems.
Consult the documentation. Any sizable application should have a well-documented API, which at minimum should include a list of all classes and their member functions and attributes. The API documentation should also tell you the file that each class is defined in. A quick search in the API would thus turn up the info you need.
Use an intelligent IDE like Eclipse that parses your code and class definitions. Eclipse has an Open Declaration function that will open up the source file where the element was declared and display the declaration.
You should always be doing the first two; the last is just a convenience.
Adobe Dreamweaver has a site wide/directory text search function as does eclipse workbench, UltraEdit and TopStyle Pro.
I am trying to use a pear installation of Doctrine, it seems like all of the Requires and Class Names are just looking in the wrong places... do I need to be updating this all in cli-config.php (or similar file)? I don't understand how to get all of these things resolved.
before I go hard-coding all of the requires, I assume there is an elegant way to get this to work. for instance...
Class 'Doctrine\DBAL\Configuration' not found in
/usr/local/pear/share/pear/Doctrine/ORM/Configuration.php on line 41
so my pear install path is /usr/local/pear and the pear doctrine install seems to be /usr/local/pear/share/pear/Doctrine
I have been reading documents, and it seems to work in the sandbox from the cli, but, I don't really have a very modern understanding of PHP. I have been looking through the documentation, and there is probably a very simple step that I am missing, but I do not see it.
try running php like
php -d include_path=/usr/local/pear/share/pear
if this works, you may be missing that path in your include_path
try to issue a phpinfo() or var_dump(ini_get('include_path')) to actually see your include path, the directory Doctrine should be located somewhere inside that path