Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Templates #7

Open
junichi11 opened this issue Mar 6, 2013 · 8 comments
Open

Code Templates #7

junichi11 opened this issue Mar 6, 2013 · 8 comments

Comments

@junichi11
Copy link
Member

e.g.

appTab
modTab
expand like the followings:
Yii::app()->caret;
Yii::app()->getModule('caret');

Remark:

It might be the same as existing code templates.
It should have a prefix(e.g. y : yapp, ymod, ..., e.t.c.).

@petrabarus
Copy link

This is a really good feature. I want to throw some ideas.

We should not just implement this for CApplication::getModule() only (http://www.yiiframework.com/doc/api/1.1/CModule#getModule-detail) but I think it also will be useful if we could do it for CApplication::getComponent()

@junichi11
Copy link
Member Author

OK, ycomTab : Yii::app()->getComponet(caret);

We have to make a list of the often used code, at first.
Or I'll add templates little by little.

Thanks.

@petrabarus
Copy link

Basically to have make a completion for the Yii::app() singleton, you have to load the configuration in the /protected/config.

because ihe array there is the one that build the CApplication instance.

.e.g.
the modules array index will fill the application modules (i.e. we can call the module using Yii::app()->getModule())
the component array index will fill the application components (i.e. we can call the component using Yii::app()->getComponent())

Usually some application can have several application config. But you can safely assume the main config is the one loaded in the index.php.

You can use the index file configuration in the PHP project setting.

Screenshot from 2013-03-13 09:47:01

and see which configuration loaded in the index file.

$yii = dirname(__FILE__) . '/yii/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php'; // <----- this one

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);

require_once($yii);
Yii::createWebApplication($config)->run();

should the programmer want to change configuration, it's his/her responsibility to change the index file..
note: this method will only work for CWebApplication, because the CConsoleApplication config loaded in different file. (But it's safe to assume a few number of people are using the console).

@PrplHaz4
Copy link

there is a yii wiki article that contains a template file as well. Might be a good reference
http://www.yiiframework.com/wiki/83/netbeans-ide-and-yii-projects/

@petrabarus
Copy link

👍

totally agree with @PrplHaz4.

I am using that guide also. I'm sure that everyone will benefit from it too.

@junichi11
Copy link
Member Author

@petrabarus
#7 (comment)
Is this related to the code template? Sorry, I don't know exactly what you want to say...

@PrplHaz4
Thanks! I want to reference it.
We can't add it soon, because we don't know license for their.

If many user use it, we might have to close this issue.

@petrabarus
Copy link

@junichi11 I'm sorry I interpreted the thread topic too far.

I thought you wanted to use some kind of autocompletion in the Yii::app()->getModule().
Clearly I was wrong.

@junichi11
Copy link
Member Author

@petrabarus Oh, I see. You don't have to say sorry :)
Thanks for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants