Search code examples
phpphpdoc

What is the right way to document usage of models?


What is the right way to document the usage of a Model A accessed in Model B? In this case i want to document the usage of Excel.

class Preview extends Eloquent {

    /**
     * Push file Data to Session
     *
     * @ ...
     */
    public static function push() {
        Session::put('data', Excel::get(self::file));
    }
}

Solution

  • You can use the @see annotation to point to another class:

    class Preview extends Eloquent {
    
        /**
         * Push file Data to Session
         *
         * @see Excel::get()
         * @see Session
         * @see http://php.net/manual/en/features.sessions.php
         */
        public static function push() {
            Session::put('data', Excel::get(self::file));
        }
    }
    

    When generating the html documentation it should create an anchor tag that links to the documentation of the Excel class's get method, the Session class. and the php.net manual