CodeIntel with PHP in Sublime Text 2 not working - php

I am trying for 2 hours now to get SublimeCodeIntel working with PHP. Well, some things work, but CodeIntel doesnt autocomplete class methods and parameters when outside of the class.
I use Sublim Text 2 for Windows (7) and the last version of the plugin.
I have a class Page in classes/Page.php, and a index.php.
In index.php:
$page = new Page('home',$_GET['page']);
And when I type
$page->
I can read in taskbar "Info: processing 'PHP': Please Wait" for a few seconds and then nothing happens.
When working in Page.php, I can start typing $this->.. and it somewhat works (actually it doesnt show functions parameters).
Same with Alt+clicking on functions and variables (only works if they are defined in the current file)
I tried several things:
1/ Deactivating "detect_slow_plugins" (error message doesn't appear anymore, but the plugin is not working better)
2/ Changing SublimeCodeIntel.sublime-settings config (copy paste the whole file and editing values):
"codeintel_language_settings": {
"PHP": {
"php": "E:/wamp/bin/apache/Apache2.2.21/bin",
"codeintel_scan_extra_dir": [],
"codeintel_scan_files_in_project": true,
"codeintel_max_recursive_dir_depth": 15
}
}
I don't even know if the "php" value is important (I found several snippets on the internet)...
3/ Same thing in Sublim Text User settings
4/ Re-building indexes as advised here
I use an PHP autoloader and I don't get how the plugin knows for sure which file defines which class. Could be an issue ?
I am completely stuck here, I tried everything I found, and read some setup tutorials (each one of them being something like "install and it just works!"... very annoying).
Does anyone have a solution? Or something to check, or try...
Thanks!

Related

Silverstripe 3.4 Module to extend image is not creating the database columns

i am sure i am missing something obvious, but this is my first attempt to actually create my own module, and the documentation just doesn't seem to be doing any good for me.
The issue is that the dependency on this new field i added seems to be working, as i get the SQL error saying that it can't find the field in the Image Table, but /dev/build is not creating the new column. I even tried manually adding the column, and then everything seems to work fine -- but this will not help for installing it onto my colleague's computers, or onto any other site.
Here are the basic files as they stand (some of the names have been changed a little, but the gist is still the same):
/tinyimage-uploads/_config.php
<?php
Object::add_extension('Image', 'TinyImageExtension');
/tinyimage-uploads/code/TinyImageExtension.php
<?php
class TinyImageExtension extends DataExtension {
private static $db = array(
'Compressed' => 'Boolean'
);
}
There are tons of methods i need to put into this, specifically onAfterUpload() -- but i can't even get this one field created. I have tried basing this off of Focuspoint Link to Github -- as this is also installed on the site, but i am just having no luck with this. All the documentation tells me that this should be enough, and some tells me that no static methods are allowed in DataExtension... but that seems to work fine in many of the other modules we have installed.
Please help, this is driving me crazy and i don't know if it just means there is something wrong with my Apache or if i am just missing some basic files for modules and just not having any luck finding the right documentation to get me started.
You can try removing/deleting the line
Object::add_extension('Image', 'TinyImageExtension');
from /tinyimage-uploads/_config.php and leave it as an empty PHP file and instead do this.
Create a new yml file at
tinyimage-uploads/_config/_config.yml and add your image extension to it like this
---
Name: tinyimage-uploads
After:
- 'framework/*'
- 'cms/*'
---
#Custom Image Extension
Image:
extensions:
- TinyImageExtension
Finally run dev/build and confirm that the Compressed Boolean data column has been created in your Image database table.
Hope this helps.

php (wordpress) - server not respond to file changes

I'm facing weird problem which a bit complicated to understand. So the situation is that:
we have 2 installs (actually more, but not relevant for now)
both installs places on same server (apache + nginx)
we update our code and therefore deploy to staging - first install works great, second one has problem.
the code is 100% percent the same
there is no influence of other plugin (wordpress) on the specific part of code
The relevant code is the following:
$track = new trackClass();
$track->store_parameters();
$parameters = unserialize($track->parameters);
class trackClass // this class sits on different file
{
public $parameters;
public function __construct() {
...
}
method...
method...
method ..
public function store_parameters()
{
...
}
}
Before we modify our code, the function store_parameters was private, now its public.
So when on the second install the code is running its raise an error that the store_paramters() function is private and not accessible (remind you that it happens only on the second install).
I tried another thing get_class_methods($track) and the response was all the methods except the store_parameters(). Again - weird.
Next step, put wp_die('test') in the top of the file of the class. Refreshing the page and all as usual (the file is definitely loaded). If I try to access the admin (wp-admin) the changes make difference - the page is killed, blank screen and 'test' on it.
Next step, remove this file completely from the server. Refreshing the page and nothing happen. Their is ajax request from the class file which run as usual, like the file is exists and everything is ok. Again, going to the admin page and the error is raised (require_once ... not found).
Its doesn't seems like its code or development problem. The code is same. I'm afraid that its something on the server side / environment (apache, nginx) but unfortunately I've no access to the linux, I only can chat with the support of the hosting company.
They are insists that is code problem. No matter the tests I wrote above.
What can cause this kind of problem? I'm losing my mind here with no lead, its like the file is stuck somewhere.

CKFinder 3 upgrade difficulty

I'm following the CKFinder 2 to 3 upgrade guide and it's not making much sense. In CKFinder 2, the PHP code provided could be used to generate the JS snippet with appropriate config and params, like this:
require_once 'ckfinder/core/ckfinder_php5.php';
$finder = new CKFinder() ;
$finder->SelectFunction = 'ShowFileInfo' ;
$finder->DisableThumbnailSelection = true;
$finder->RememberLastFolder = true;
$finder->Id = $name;
$finder->StartupFolderExpanded = true;
$finder->Width = $width;
$finder->Height = $height;
echo $finder->CreateHtml();
This code picks up the config and incorporates it into the generated JS.
In 3 this seems to have disappeared entirely - the upgrade guide describes the changes needed in config.php, but there is no indication of how this is ever used since there is no other PHP involved, and it says
It is no longer possible to enable CKFinder on a page from the PHP level
All that is shown is how to create the JS snippet, which does not contain any config, and so will use incorrect settings. There is no indication of how the config properties set in config.php ever get to the JS code - as far as I can see there is no connection at all and no mention of any other PHP files, even though some are provided but not documented.
This makes no sense - PHP can quite happily generate HTML and JS that is run on the page, which is all the old CreateHTML function did. I don't understand why there is no mention of this mechanism since it was how we were supposed to use CKFinder previously - it's as if the migration guide is for some unrelated package!
If I update the config file and use the default JS widget code as suggested, it breaks the page completely, altering the MIME output type so it does not get rendered as HTML and appends this error:
{"error":{"number":10,"message":"Invalid command."}}
The docs cover various fine details of what PHP config settings mean, but nowhere that I've found says how it's ever loaded, triggered or associated with the JS. How is this supposed to work?
Indeed the CKFinder 3 documentation was lacking some important information. We're gradually adding new articles there. Based on topics you mentioned I just added:
Explanation how PHP code that worked for CKFinder 2 can be refactored to plain JavaScript in CKFinder 3. Should look familiar ;)
A table with Configuration Options Migration - JavaScript Settings which should help you with discovering again options like rememberLastFolder

How to add comments to each forum post in yii, using bbii forum module and comments-module

I am using Yii bbii forum module and it works fine. But now I want to add comments-module so every forum post could be seperately commented.
At the begining it might look:
I followed instruction what is here, but I can't make it work :(
And why I even need to include this file, if I want to add just comment?
When I added the same widget to user page (just for testing) - I got "This item cann't be commentable" and it's fine because probably I don't have correct configuration in main.php.
Difference between widget in user model view and forum view is data passed in it.
Here:
public function actionPostComment()
{
if(isset($_POST['Comment']) && Yii::app()->request->isAjaxRequest)
{
$comment = new Comment();
$comment->attributes = $_POST['Comment'];
var_dump($comment);
var_dump returned this when tried to submit comment in forum, and here in user view page.
And probably it is not even possible to combine these to modules? I'm really new in Yii.
Updated:
Basically what I have done is:
exstracted comment module (under protected->modules)
in main.php (under protected->config) added all cofiguration in modules array:
'comments'=>array(
//you may override default config for all connecting models
'defaultModelConfig' => array(
//only registered users can post comments
'registeredOnly' => false,
'useCaptcha' => false,
.......
and in view file _post.php added following:
<?php $this->widget('comments.widgets.ECommentsListWidget', array(
'model' => $data,
));
and var_dump($data) gives this (when this is called in controller where post is reseaved).
An error message was given here:
include(BbiiPost.php): failed to open stream: No such file or directory
You said that the Bbii was working with Yii and it broke when you tried to add comments.
The links to your var_dump files are broken, but I did try to read them ;)
It looks like the comments module is interfering with the POST path so that when the form submission comes in it is in a different path from the root which is confusing the YiiBase's autoloader.
You could try explicitly adding the path to BbiiPost.php to the autoloader's search path, or finding where the include("BbiiPost.php") line is and changing it to an absolute path.
Another possibility is that the forum page you are on has links to add comments but the page routing has not been taken from the route. So it might be that the POST link to the comments is actually at /forum/123/comment/add instead of just /comment/add. So when the form is submitted it is trying to the comments/add controller/action but finding that it is in /forum/view and getting confused about the paths to the include files.
I have generally found that the instructions on the Yii (v1) [v2 docs are much better] site for these modules is flaky at best. Quite often the source download link on the page points to an old buggy version of the code as the project has usually moved somewhere else. You generally need to have a pretty good PHP/Yii knowledge to debug these user-submitted modules and get them working.

Problem with prototype framework in cake php

This question is somewhat related to my previous question (not necessary to go through it)
link text
, although this one is more of an Ajax problem.
I tested my page in firebug and I am getting the following error
Event.Observe is not a function
Event.observe('form908983160', 'submit', function(event) { new Ajax.Updater('comments','/blog/posts/comments/add', {asynchronous:true, evalScripts:true, parameters:Form.serialize('form908983160'), requestHeaders:['X-Update', 'comments']}) }, false);
I am using the prototype framework for developing my cake php application.
How should I fix this problem?
Guys, I really need your help in this one. I am really stuck at this one. [:(]
prototype.js has to be :
loaded in the page (verify it's not in 404, for instance)
loaded in the page before the execution of your script
Which generally means you need to include prototype.js first, and, only after that, you can include your scripts.
As a sidenote : you are not using any other JS Framework in that page, of course...
Remember that any Event.observers need to be used in global
Event.observe(window,'loaded',f);
// or
Event.observe(document,'dom:loaded',f)
otherwise they will not work.
For me it looks like there's problem with linking to Prototype. Open firebug and try to see the contents of your script files - if you see html, that means something went terribly wrong :-)

Categories