Question

I have recently installed PHPDocumentator 2 and like it so far. One thing I would like to do is organize the files in a more meaningful way (specifically by using the actual folder structure) and in alphabetical order.

Here is a screenshot of my classes as it stand now:

enter image description here

Note that they are not in alphabetical order at all. The actual folder structure is like so:

system/
  - Database
  - all Form classes
  - Tester
extra/
  - Registration
  - ConfigForm

I'm not using namespaces, but I have @package's on all of the classes.

Can I fix this in phpdoc.dist.xml or do I need to create a new template?

Any advice would be greatly appreciated!

Edit: Here is a sample docBlock:

/**
  * FormElement Class
  *
  * @category System
  * @package  Form
  */
abstract class FormElement
{
Was it helpful?

Solution

In sampling the various output templates available with phpDocumentor 2.1.0, I see that some do alphabetize that left-side listing, while others do not. It is possible, even likely, that those that do not alphabetize the list are bugs in those templates.

Regarding your organizing via @package, your expectations are correct. However, I see in your image that you are showing the "\" global namespace listing rather than the Packages listing. You'll want to choose a template based on how it presents the Packages view. I'd suggest trying the Abstract template first and see if it fits your liking. I see that it alphabetizes its listing of Packages, as well as its list of Classes in a Package.

OTHER TIPS

Sorry for my bad english

I had the same problem (with PHPDocumentator 2 too)!

The solution of @ashnaz of using @package in the class's comment, as they say in the documentation of PHPDocumentator, WAS NOT working in the left menu, but did show the package in the right menu!

After hours of searching, I find out how to group my classes in the left menu!

In all the files I want in my documentation, I add a namespace. In my case, namespace's name is the folder/directory my classes were into. But you can group the classes with the names you want! So here the solution :

  • Add a namespace in all the classes you want to group together

    • To group classes together, they need to have the same namespace
    • You can have multiple namespaces!
  • The namespace line must be the FIRST LINE OF CODE IN THE PAGE !! So directly under the <?php line ! The beginning of the class should look like this :

    <?php 
    namespace GroupName;
    

    and run your phpdoc command (I use phpdoc -m --validate --force) and you should have the left menu with the structure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top