IntelliSense not working in some files.
8 posts
• Page 1 of 1
IntelliSense not working in some files.
Hi there,
I am working on a CakePHP project and there seems to be no IntelliSense in some files. For example I have the following file:
index.ctp (I have mapped the .ctp file extension to PHP Editor in the VS options)
I can't goto definition on the link method. How can I get this to work?
Do I have to add a reference to the file that has the class with this method to the index.ctp somehow?
Some info regarding CakePHP:
You might have noticed the use of an object called $this->Html. This is an instance of the CakePHP HtmlHelper class. CakePHP comes with a set of view helpers that make things like linking, form output, JavaScript and Ajax a snap. You can learn more about how to use them in Helpers.
http://book.cakephp.org/2.0/en/views/helpers.html
I am using VS2012, on Windows 7 and all the above code is rendering correctly in the browser.
Regards,
Scott
I am working on a CakePHP project and there seems to be no IntelliSense in some files. For example I have the following file:
index.ctp (I have mapped the .ctp file extension to PHP Editor in the VS options)
- Code: Select all
<h1>Blog posts</h1>
<table>
<tr>
<th>Id</th>
<th>Title</th>
<th>Created</th>
</tr>
<!-- Here is where we loop through our $posts array, printing out post info -->
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td>
<?php echo $this->Html->link(
$post['Post']['title'],
array(
'controller' => 'posts',
'action' => 'view',
$post['Post']['id']
)
); ?>
</td>
<td><?php echo $post['Post']['created']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($post); ?>
</table>
I can't goto definition on the link method. How can I get this to work?
Do I have to add a reference to the file that has the class with this method to the index.ctp somehow?
Some info regarding CakePHP:
You might have noticed the use of an object called $this->Html. This is an instance of the CakePHP HtmlHelper class. CakePHP comes with a set of view helpers that make things like linking, form output, JavaScript and Ajax a snap. You can learn more about how to use them in Helpers.
http://book.cakephp.org/2.0/en/views/helpers.html
I am using VS2012, on Windows 7 and all the above code is rendering correctly in the browser.
Regards,
Scott
- codeowl
- Posts: 51
- Joined: February 10th, 2013, 10:05 am
Re: IntelliSense not working in some files.
I am also working with CakePHP, but as this is nothing "generic" I did not complain about this...
In the controller I got my helpers/components via PHPDoc tags, which works fine.
Maybee something "generic" could be implemented to support "generic template engines", like a "/* @baseclass BaseController */" at the top of a PHP file, to tell IntelliSense, that the file is in the "class context of BaseController".
In the controller I got my helpers/components via PHPDoc tags, which works fine.
Maybee something "generic" could be implemented to support "generic template engines", like a "/* @baseclass BaseController */" at the top of a PHP file, to tell IntelliSense, that the file is in the "class context of BaseController".
- CFI
- Posts: 66
- Joined: December 13th, 2012, 1:29 pm
Re: IntelliSense not working in some files.
Hi,
Please check whether the script file with non-.php extension has highlighted PHP syntax (close it and reopen is probably needed).
Once scripts are highlighted, they should be visible for IntelliSense too.
Thanks,
Please check whether the script file with non-.php extension has highlighted PHP syntax (close it and reopen is probably needed).
Once scripts are highlighted, they should be visible for IntelliSense too.
Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: IntelliSense not working in some files.
IntelliSense in general works.
It just does not know "what $this is" - and this is the problem, as there is no "generic way" to find out.
For example in CakePHP in the file "ROOT/View/Home/index.ctp" $this would be an instance of HomeController from "ROOT/Controller/HomeController.php".
As this is something "framework dependant" I suggested the somehow generic approach of e.g. adding a comment at the top of "index.ctp" like "/* @baseclass HomeController */" to tell IntelliSense what to use for $this.
It just does not know "what $this is" - and this is the problem, as there is no "generic way" to find out.
For example in CakePHP in the file "ROOT/View/Home/index.ctp" $this would be an instance of HomeController from "ROOT/Controller/HomeController.php".
As this is something "framework dependant" I suggested the somehow generic approach of e.g. adding a comment at the top of "index.ctp" like "/* @baseclass HomeController */" to tell IntelliSense what to use for $this.
- CFI
- Posts: 66
- Joined: December 13th, 2012, 1:29 pm
Re: IntelliSense not working in some files.
Yes, $this is known issue ... it is very special variable name, and in case of global code, it is very difficult to find out what type it is ... we are ignoring $this for now, but we are open to any suggestions, eventually we can make it working for certain frameworks.
Thanks!
Thanks!
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: IntelliSense not working in some files.
Jakub,
Thanks for quick the response again. Yes mate the highlighted PHP syntax is working, as I have set-up the .ctp extension in the File Extension options, and IntelliSense for standard PHP functions is working.
The issue is described well by CFI (thanks for your input mate , and his suggestion is a good one:
"As this is something "framework dependant" I suggested the somehow generic approach of e.g. adding a comment at the top of "index.ctp" like "/* @baseclass HomeController */" to tell IntelliSense what to use for $this."
Is there anything like this in PHP Tools?
BTW: Great to see an active forum here, and good support. Thanks to all participating
Regards,
Scott
Thanks for quick the response again. Yes mate the highlighted PHP syntax is working, as I have set-up the .ctp extension in the File Extension options, and IntelliSense for standard PHP functions is working.
The issue is described well by CFI (thanks for your input mate , and his suggestion is a good one:
"As this is something "framework dependant" I suggested the somehow generic approach of e.g. adding a comment at the top of "index.ctp" like "/* @baseclass HomeController */" to tell IntelliSense what to use for $this."
Is there anything like this in PHP Tools?
BTW: Great to see an active forum here, and good support. Thanks to all participating
Regards,
Scott
- codeowl
- Posts: 51
- Joined: February 10th, 2013, 10:05 am
Re: IntelliSense not working in some files.
Thank you!
We are planning new release soon, following PHPDoc syntax can be supported for this case?
We are planning new release soon, following PHPDoc syntax can be supported for this case?
- Code: Select all
/**
* @global TypeName $this
*/
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: IntelliSense not working in some files.
The PHPDoc syntax is also great and would fullfill all needs.
- CFI
- Posts: 66
- Joined: December 13th, 2012, 1:29 pm
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 20 guests