PhpStorm autocomplete new file and class not work - php

When I create new file in PhpStorm, it does not complete anything and the page is blank.
For example, when I create a class named Database it should create a file with this ready code
<?php
class Database{
}
but nothing happened and the page is empty.

I assume you are talking about code templates. In such case I recommend you to visit JetBrains help page and ensure that you have your templates installed correctly.
Please, check your template and see, if it is set like this:
If you have it setup correctly, you should be able to see a prompt for a class name and namespace, please, fill out the form and PHPStorm will generate the file for you. If it does set correctly, try to reinstall the software.
Please, check if you are using actual version of PHPStorm and have a license for it.
If none of this will help, use menu Help -> New Support Request. JetBrains has a very good support team.
UPDATE1:
PHP Class template
<?php
#parse("PHP File Header.php")
#if (${NAMESPACE})
namespace ${NAMESPACE};
#end
class ${NAME}
{
}
Now switch to Includes tab. There should be template like this
PHP File Header.php template content (file name and extension must match the one from #parse() directive):
/**
* ${PROJECT_NAME}
* ${FILE_NAME}
*
* PHP Version 5
*
* #category Production
* #package Default
* #date ${DATE} ${TIME}
* #license http://${PROJECT_NAME}.com/license.txt ${PROJECT_NAME} License
* #version GIT: 1.0
* #link http://${PROJECT_NAME}.com/
*/
I recommend you to reinstall PHPStorm, it should have those templates.

Related

PHPDocumenter No summary for class

I am using PHPDocuementer and I keep getting these messages for my classes:
Parsing /code/vendor/prodigyview/helium/app.class.php
No summary for class \prodigyview\helium\He2App
But when code is the following:
<?php
/**
* The main application for instantiaing the He2MVC Framework and bringing together the parts required for the system to work.
*
* The application is what is called with Helium is first initiliaed in the frontend controller. It will autoload the components,
* set the registry and then send the application into the router. The boostrap of the framework should be called sometime during
* this point.
*
* #package prodigyview\helium
*/
namespace prodigyview\helium;
class He2App extends \PVStaticInstance {
}
Am I missing something?
The one docblock you have should be moved down to just above the class line. Its current location is being interpreted as the file-level docblock rather than a class-level docblock.
After doing this, you might start seeing warnings about file-level docblock missing. Just add a new docblock at the same place you have the current example one. You could use an exact copy of the one you already have up there, since its content seems to fit for the file as well as the class.

How Phalcon design pattern works?

I am recently start working on Phalcon. It is very good framework. I am trying to understand the design pattern of this.
Suppose that i am working on Form module. There is a class named Text and i am using this as $text = new Text("field_name");, Text class in included from use Phalcon\Forms\Element\Text;. Now i checked this namespace directory and found the Text class but there are only a render function. Here it is-
namespace Phalcon\Forms\Element;
/**
* Phalcon\Forms\Element\Text
*
* Component INPUT[type=text] for forms
*/
class Text extends \Phalcon\Forms\Element
{
/**
* Renders the element widget
*
* #param array $attributes
* #return string
*/
public function render($attributes = null) {}
}
Nothing is here for create a form element so i checked the parent class of Text but also this is inherited by an interface and its only define the all fucntions which present in its parent interface.
There are no defication for create a form elemet. Then how it's works?
How it can produce the code for an form element?
I also find such things in another module also. Please explain, is this any design pattern in oops?
I also works in npm and also checked packages they also have same design pattern.
You just checked php stubs. Phalcon is framework working as php extension wrriten in zephir which is translated to C and then compiled as extension and you can't edit and check it source code so easy.
Here you have this class - https://github.com/phalcon/cphalcon/blob/master/phalcon/forms/element/text.zep
First i think you should learn and check docs what you are actually using before start using it.

In the Eclipse PDT, is it possible to configure content assist to look for alternative tags to suggest PHP types?

I'm working on a project that uses the Lithium (http://li3.me/) framework and they document their classes like this:
class Controller extends \lithium\core\Object {
/**
* Contains an instance of the `Request` object with all the details of the HTTP request that
* was dispatched to the controller object. Any parameters captured in routing, such as
* controller or action name are accessible as properties of this object, i.e.
* `$this->request->controller` or `$this->request->action`.
*
* #see lithium\action\Request
* #var object
*/
public $request = null;
I've always used fully qualified class names in the #var and Eclipse seems to do a good job with that for generating content assist. However they seem to document class names using #see tags instead, and content assist is not available. Is there a way to configure PDT to use the information in the #see tag as a class name for the purposes of content assist?
It's not possible without own plugin. #see tag should be used for links only.

Phpdoc page level error in codeigniter

Hi I have created a project using codeigniter. Now I am trying to generate phpdoc. This is my first time using phpdoc and i have read their documentation and other tutorials. When I try to generate i get list of error mostly it is
.... has no page-level DocBlock, use #package in the first DocBlock to create one
and nothing has been generated. But when i run phpdoc inside controllers or models folder it works but doesnt run from root folder nor from application folder. Where Am I going wrong?
Here is the sample of docblock starting
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
* Project 1 files
*
* #package Project1
* #subpackage projectControllers
* #author Abhishek Salian
* #copyright Copyright (c) 2013, AS.
* #link http://localhost/project1/
* #since Version 1.0
*/
?>
For every method
/**
* index
*
* This loads the index page
*
* #access public
*/
Error:
Abhis-MacBook-Pro:~ abhishek$ sudo phpdoc -d /Applications/mamp/htdocs/NewFrontend/ -t /Applications/mamp/htdocs/Docs/
PHP Version 5.4.10
phpDocumentor version 1.4.4
Parsing configuration file phpDocumentor.ini...
(found in /Applications/MAMP/bin/php/php5.4.10/lib/php/data/PhpDocumentor/)...
done
Maximum memory usage set at 256M after considering php.ini...
using tokenizer Parser
Hidden /Applications/mamp/htdocs/NewFrontend/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.git Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.gitignore Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.htaccess Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/.travis.yml Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/application/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/application/config/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/application/libraries/tcpdf/tools/.htaccess Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/images/.DS_Store Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/lp/.htaccess Ignored
Hidden /Applications/mamp/htdocs/NewFrontend/lp/m/.htaccess Ignored
Grabbing README/INSTALL/CHANGELOG
done
Tutorial/Extended Documentation Parsing Stage
done
General Parsing Stage
Reading file /Applications/mamp/htdocs/NewFrontend/application/cache/index.html -- File not parsed, not a php file
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/autoload.php -- Parsing file
WARNING in autoload.php on line 115: File "/Applications/mamp/htdocs/NewFrontend/application/config/autoload.php" has no page-level DocBlock, use #package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/constants.php -- Parsing file
WARNING in constants.php on line 40: File "/Applications/mamp/htdocs/NewFrontend/application/config/constants.php" has no page-level DocBlock, use #package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/database.php -- Parsing file
WARNING in database.php on line 135: File "/Applications/mamp/htdocs/NewFrontend/application/config/database.php" has no page-level DocBlock, use #package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/development/config.php -- Parsing file
WARNING in config.php on line 611: File "/Applications/mamp/htdocs/NewFrontend/application/config/development/config.php" has no page-level DocBlock, use #package in the first DocBlock to create one
Reading file /Applications/mamp/htdocs/NewFrontend/application/config/doctypes.php -- Parsing file
phpDoc looks for a file-level docblock to appear before any code. Because that "if" in line 1 has no docblock before it, you get that error. The docblock that you do have, after that "if" line, would be associated with whatever code element happens to appear after it, whether it's a class, a function, even just an include/require line.
The only way you can "solve" that error is to put a docblock before that top "if" line. That docblock will need at least the #package tag in it, if nothing else, since this appears to not be namespaced code.
Like this:
<?php
/**
*
* Project 1 files
*
* #package Project1
* #subpackage projectControllers
* #author Abhishek Salian
* #copyright Copyright (c) 2013, AS.
* #link http://localhost/project1/
* #since Version 1.0
*/
/** no direct access */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// now more stuff...
It might be necessary to have a docblock like that "/** no direct access */" in front of the IF line to, so that the parser does not tie the "Project 1 files" docblock to the "IF" line itself.

Netbeans: PhpDoc formatting

How to automatically format PhpDoc comments in Netbeans?
I'd like to have comments aligned like this:
* #author Author Name <example#example.com>
* #package Doctrine
* #subpackage Table
* #license http://www.opensource.org/licenses/lgpl-license.php LGPL
* #version $Revision: 67999 $
* #link www.phpdoctrine.org
* #since 1.0
When I type /**[Enter] in Netbeans, it automatically imports all parameters as #param from the method definition. But then, when the comment is already generated I add a new variable to the definition. What now? How to trigger comment reparse and add newly added parameter?
Not possible in current version. I just use TAB to align the docs.
Not sure if this will work, but its a formatter that allows you to create a custom profile where you dictate the spacing/indentation of everything from your comment blocks to your class, field, methods declarations. It allows you to be able to hit Ctrl+F to have your code automatically format according to what you specify in your profile. Great way of maintaining the appearance of your code for readability without the manual labor involved.
http://en.sourceforge.jp/projects/pdt-tools/

Categories