In IntelliJ, you can generate JavaDoc by going to Tools -> Generate JavDoc. When you have a Static Web PHP project, however, JavaDoc will not work, throwing the error that no Java classes could be found.
Now, what I need is to generate actual PHPDoc. My functions and classes already have the necessary PHPDoc comments in the source code. How is it done, if it's at all possible without having to resort to PHPStorm?
I haven't been able to find the answer anywhere on StackOverflow or in the IntelliJ documentation. All I have found was how to have IntelliJ automatically generate the necessary PHPDoc comments based on the function signature, but what I wanna do is export them to standalone HTML files.
Go to Run -> Edit Configurations... then add a new PHP script. In the File field, point to the location of phpdoc on your machine. In the Arguments field, add something like this, taking into account whatever extra arguments you may need:
-d /path/to/code -t /path/to/target/directory
Name the script, hit OK to save your changes, and you should be good to go. It'll be added to the dropdown of Run/Debug Configurations.
Related
I'm attempting to implement some quality control on a project, and I've removed all warnings for my project according to a specific profile in the PhpStorm code inspector. Now I want to set up an automated check (maybe a git hook or Jenkins job) so that people don't add additional warnings.
Basically, what I need to do is to run PhpStorm's code > inspect functionality from the command line.
It appears that, by default, PhpStorm uses some kind of internal code inspection tool when I run code > inspect code. It has plugins for PHP Code Sniff and others, but I don't really want to use those. For example, PHP Code Sniff finds all kinds of spacing errors and such (it's a linter, after all), but it doesn't detect things like passing the wrong number of arguments to method signatures (i.e. the stuff I really care about).
So, is there any way to run PhpStorm's code inspection external to PhpStorm?
Hmmm...
Looks like posting this question may have given me the clarity I needed to search for the correct answer. Looks like there's a way to do this outlined in the PHPStorm documentation:
https://www.jetbrains.com/help/phpstorm/command-line-code-inspector.html
I'm curious on how certain php functions are implemented internally. e.g. array_values().
So in eclipse, I control click on the function name, which took me to a page that contain function prototype definition, but contains no internal source code.
Is there any way to see the internal implementation of php function using eclipse? (whether the function is written in php or c)
If it is not possible to see the php source code using eclipse, then does anyone have any good strategies at searching through the php source code on github?
Is there any way to see the internal implementation of php function using eclipse?
Unfortunately, no.
what is the best search strategy to search through the php source code, especially for a beginner like me, who feels very much lost in the vast amount of php source code
I'm assuming what you are really after here is a reference for native PHP functions and their input parameters and out types. In which case the official documentation is probably the best way to go about it.
Some (most?) popular IDEs such as Eclipse and Phpstorm can also give you an auto-generated phpdoc block for PHP's built-in functions that will give that information directly in your IDE.
If you are interested in the actual C implementation of most php functions, you can either navigate through the GitHub repository directly or clone it on your computer and open it in an IDE (Eclipse, CLion, etc...) and use the IDE navigation.
You can download the PHP source code from GitHub (https://github.com/php/php-src)
but the core of PHP is written in C language.
Use notepad++ to search the required details from the downloaded source code.
For example code for PHP array will be in this file :
https://github.com/php/php-src/blob/master/ext/standard/array.c
Notepad++ is the good editor with a lot of additional functionality like search string through files. (Find in files)
Hope it helps
Thanks
As an alternative, consider running OpenGrok in a Docker container. OpenGrok is an open-source and free source code indexer with advanced search mechanisms. (I am not affiliated with the project in any way)
Setting it up is easy (assuming you have Docker already installed):
# Make a directory that will contain source files for opengrok to index
mkdir ~/opengrok
# Clone the PHP source into that directory
git clone https://github.com/php/php-src.git ~/opengrok/php-src
# Start the OpenGrok container
docker run -d -v ~/opengrok:/src -p8081:8080 opengrok/docker
Now you should wait a minute or two for OpenGrok to fully index the source tree.
Open your browser
We want to search for the array_values implementation
Select the implementation in array.c
There you have it! The C implementation of array_values.
phpDocumentor v1.4.4
Fedora 24
Command line: phpdoc -d ./docsrc -t ./output
I am running phpDocumentor on Fedora 24 and have successfully generated documentation for my project one time.
I added a docblock to a function, and ran phpdoc again. But the output has not been updated. I verified the time stamps of the files and they have been regenerated, but do not reflect the changes.
I subsequently made numerous changes, and reran phpdoc after each change, but the generated documentation does not update.
I erased all the output files, renamed the directory of the input files, in short have done all I can to persuade phpdoc to generate new documentation that reflects the changes to my php files to no avail.
It would seem that phpdoc is caching the output somewhere but I cannot find where. I searched every path on my disk containing phpdoc then searched for the word "cache" in each path but it does not occur.
I tried changing the template with the --template directive but it does not recognise this directive.
I have tried using the --force directive but it does not recognise this directive.
Can someone enlighten me?
Cheers,
Peter
This sounds like one of those times where I would just walk through the process from the beginning:
Am I modifying source in the ./docsrc directory tree? Verify by opening the source member in vi/vim/nano/some-other-editor just to be sure the source has changed.
Have I modified the source using the correct syntax? (Please post some code that shows documentation that isn't being updated)
Modify documentation in another file with a simple change and see if that simple change appears when I regenerate my documentation.
Am I explicitly --ignore-ing the file or directory I'm expecting to change? (You don't appear to be)
Do I have a phpdoc.xml or phpdoc.dist.xml file with an <ignore> directive? details
Do I have the necessary permissions to create/update files in the ./output directory?
After I've executed phpdoc -d ./docsrc -t ./output do I see the expected change when using vi/vim/nano/some-other-editor?
Is my browser caching previous versions of the documentation? (I know you've already ruled this out Peter, I'm just trying to make my answer complete)
This is EXACTLY one reason why I created PHPFUI/InstaDoc! The problem with most documentation is that it is static. While that is great for libraries that don't change, if you want to document your own code, guess what? It tends to change every day! With InstaDoc, you can see the documentation instantly on your local machine before you even check it in. InstaDoc creates the documentation when you request the page. It is hands down the fastest documentation system out there. Most documentation systems create static pages and brag about how fast they can create the documentation. But guess what? Who cares? What you want is to see the documentation of your current code base right now. Turns out it only takes a few seconds to scan through all the files of the libraries you are using. InstaDoc caches that information, so you only have a long scan (and then only seconds) the first time, or when ever you add a new library.
Once you have a library scanned, the documentation comes up instantly, since it uses PHP reflection classes to read the file and display the documentation. So that file you just modified, it is completely 100% documented. Don't like the comments, change them, refresh the page. See an issue, correct it, refresh the page. Notice something could be better? Refresh the page. Want to check out the docs on a PR? Easy, just delete the cached index and refresh the page.
InstaDoc is open source and still young. Check it out and submit comments or PR's if it does not meet your needs, but it is the future of documentation. It will also generate static files for high volume sites, but the most important feature is that it gives you an instant reflection of your just edited code, and that is what makes it awesome.
I have Jenkins CI.
Source code is PHP.
Jenkins grabs every 5 minutes source code from GIT.
How to configure to scan source code for resticted words:
sqlsrv_
mssql_
I need it to monitor another developers to avoid using deprecated functions in code.
What you need is a static code analysis tool for PHP. Then you need to configure Jenkins to launch that tool.
There are tons available.
Here is a question listing many static code analysis tools for PHP:
Is there a static code analyzer [like Lint] for PHP files?
Here is a question about linking one of those (PHP Code Sniffer) with Jenkins:
Using Jenkins and Php Code Sniffer
I would suggest you define Sniffs (Custom based sniffs) and those can grab The mentioned words whenever they appear. You can then make your build fail or display error message accordingly.
I have been able to create my own Sniffs after seeing how Sniffs are developed in:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
Hope this helps.
I have a PHP client and want to communicate with Subversion server using cURL & WebDav. Please guide me how to write PHP code to do something like svnrdump tool offers?
I suggest you use the SVN library that comes with PHP. All the svndump tool does is to just get each individual changeset and apply it to a new repository, so you'd probably want to use svn_repos_create, then use svn_log to find the number of changesets to download, then a combination of svn_checkout on the remote repository and svn_checkin to apply the changeset to your new repository, followed by duplicating the message.
Edit: There is also a method called svn_repos_hotcopy which may do all of the above. Unfortunately, there is no documentation at all. My guess is that this maps to the c function in SVN, and you can view the source code to see if this would help you (my guess is yes, assuming the PHP call works).