Autocomplete classes in includes - VS Code PHP Intellisense - php

I'm trying to migrate from PHP Storm to VS Code but there's a little issue that is bothering me.
I'm using PHP Intellisense (tryied Intelliphense too), configured it as the instructions asked (I Have PHP 7.2 and PATH set correctly), my project was opened as a folder.
So here's whats going on (examples):
require('incs/DB.php');
$con=new DB(configs,goes,here);
DB included and configured to use. If I try to type: "$con->" suggestions appear as they should (GREAT!)
Now another file:
index.php
require("config.php");
...more code...
If in this file I try to type "$con->" nothing that matters shows up. The suggestions have nothing to do with the class "$con" is using.
So, did I make something wrong or is this a common thing in the extension? Can I only call for suggestions on the same file that "created" the class?

Related

When running "php bin/console list", Symfony prints the code for several classes inside the "src/Admin"-directory

I've taken over a code base of a Symfony 4.4-project, with a couple of extra bundles installed (Sonata being the biggest one). When I write: php bin/console list, then it prints the source code for several of the classes in the src/Admin-directory. And I can't figure out why.
I've searched the code for print, var_dump and dump, but can't figure out where this is.
I'm not familiar enough with Symfony, to go through the code 'from the top', adding my own dump-statements, narrowing it down, where this code is coming from.
Had this been Laravel, then I would have started in the routes, then moved on to maybe the kernel or middleware, then to the controlles - and in the end the views.
Does anyone have a good suggestion on which files to add dump-statements to, to see where this code is coming from?
... Or if anyone else has a good idea on how to find this code, then I'm all ears.
Is it maybe an entire namespace that is printed? And can one even do that?! Hmm...
This is what it looks like:
You'll get this behavior if the code you've inherited uses short open tags <? but your personal dev environment's PHP installation has them disabled. Run php --ini to find where your ini file is and then edit that to change from this:
short_open_tag = Off
To this:
short_open_tag = On
Alternatively, you could edit all the source files and change the short open tags <? to long open tags <?php.

PHPstorm - Unable to set breakpoints in blade.php files

I'm working on a Laravel application and can debug my controller php files fine, but Id like to also debug the blade.php files. With my current setup Ive followed all of jetbrains recommend settings for Laravel, (https://confluence.jetbrains.com/display/PhpStorm/Laravel+Development+using+PhpStorm#LaravelDevelopmentusingPhpStorm-DebuggingLaravelApplicationswithPhpStorm) but it is still not allowing my to set breakpoints in the blade.php files.
What could I be missing?
Putting a
<?php xdebug_break(); ?>
into your blade file works pretty well.
Even in my tests, PHPstorm jumps to the next PHP statement in some cases.
Why this works:
Laravel processes the blade file to a normal PHP file in the cache folder. But the PHP statement xdebug_break(); will be transferred there and cause the program to halt at the position you want it to (in the cache file).
Go to your Jetbrains IDE Settings (Ctrl+Alt+S; ⌘+,; etc.)
Languages & Frameworks > PHP > Debug > Tempates
Enter in Blade Debug > Cache path: \path\to\app\storage\framework\views
Enjoy
To close this question - phpstorm doesnt support this functionality at the moment. A work around provided by jetbrains support was to add *.blade.php to file type associations under PHP in the IDE settings, however, it still wasnt working for me after doing this.
It appears that they created a youtrack ticket in response to my request, if youd like to encourage jetbrains to work on this please upvote: youtrack.jetbrains.com/issue/WI-26476
Even if you can get the IDE to enable breakpoints on the blade files, it won't work - Laravel composes a PHP file from the Blade file - it is this file that is eventually used when the script is run - not the Blade file.
A Work-Around
This works for PHPStorm - but something similar might be possible in other IDEs.
Laravel (5) stores the composed files under storage/framework/views.
These files have random generated file names - so it may be tricky to find the file you want.
An easy way is to delete all these temp files and then refresh the page you want to debug. A new file will be created.
In PHPstorm you can right-click on the file and select the file's extension type. (Not sure about other IDEs)
You will now be able to set breakpoints. Obviously you will need to make the changes in the Blade file - but this will at least help you to figure out what is wrong.
**Update: Alex's solution is easier! **
I devised an even better hack, which allows conditional debugging support, so that you aren't stuck with XDebug_break for the rest of eternity.
The single line expands as follows.
<?php if ( \app\utils\DebugLogger::EnableForBlades ( ) ) xdebug_break ( ) ; ?>
This statement has a couple of unusual features.
Since blade files done't have use directives, the method name, \app\utils\DebugLogger::EnableForBlades is fully qualified.
Since blade files seem to lack support for the usual code blocking mechanism, the one-line statement is devoid of braces, and is terminated by a semicolon.
EnableForBlades is a static method that queries an environment variable (one of those defined in .local.env), returning True if that variable evaluates to True. Otherwise, it returns False, and xdebug_break is suppressed.

Can't Get Aptana Studio 3 Autocomplete/Code Assist To Work?

Before you answer let me explain. It works fine with local projects LOCALLY but not over FTP even with PHP class files are in the same directory.
For example if I have a file I'm including using require 'happyclass.php'; in my index.php file and I want to use a class that's in happyclass called happy I can do something like
$happy = new happy();
it will suggest the class and also autocompelte and auto-show PUBLIC METHODS AND FIELDS ETC OF THAT CLASS!
So for example say there was a public method called beHappy() in the happy class then when I did this
$happy->
The problem would still auto-show beHappy() as a public method of that class and suggest it. All I have to do is press enter.
This works fine locally but NOT IF I'M USING THE CONNECTIONS MANAGER for FTP built into aptana. My workaround has been using synchronization from local to remote but this is annoying and seems unnecessary.
What can I do? Thanks for the help guys!
That how I get it to work:
create new project make sure PHP.
Right click on project icon.
PHP Buildpath - click add and choose folder witch all your classes.
OK
Bit lower Project Natures makes sure PHP is Primary;
OK
sometimes restart Aptana 3 and autocomplete working fine;

Installing Zend Gdata Client library

Hi this is my first post on here. I am trying to install the Gdata Zend Client library without much success.
I have used these resources + scoured Stack Overflow.
https://developers.google.com/gdata/articles/php_client_lib
http://jeromejaglale.com/doc/php/google_calendar_api
I want to be able to add,edit etc events on google calendar via PHP. My problem/question is i really dont understand what the include_path settings are all about and how to set them in order to make the class work. Of course i checked php manual regarding this but still draw a blank.
I have downloaded the relevant class and uploaded it to my web root. In the past i would just include a class by using php include at the top of the page and this would suffice.
I am of the understanding that i need to change the php.ini file to show php where my class is. Does this mean that i have to put my class somewhere else other than the web root.
I am terribly confused about this step and i know that if i can get it installed, actually using the class should be relatively easy.
Thanks for any help.
Welcome! Your Q is about include files rather than ZF elements.
Understanding where the include setting can be made (and subsequently overridden) is an absolute key bit of information.
You need to find out where it is on the server you are working on.
echo ini_get('include_path');
Then dash off and really, really read the corresponding manual page.
Try out including a very simple file with an echo statement, and you will regain your sanity and confidence.
http://www.php.net/manual/en/function.include.php
Get that working then have a play with this:
http://www.php.net/manual/en/function.ini-set.php
The experience how you can include a file from the same directory (not generally a good idea if that is a public webpage - inside your webroot)
Then if you want to really chase this thing down, look at where you can set this in Apache and per-directory in .htaccess files.
Finally, you can just include a file by telling include/require the exact path from the top of the tree;
include /var/www/includes/libraries/and/so/on.php;
There are SO many places you can set and override this that you are really best off finding out where the server thinks the include directory is and putting your compoenents in there:
Now, when that comes to ZF stuff, I (on Deb and Ubuntu anyhow) put the contents of
Zend Framworks version XYZ ZendFramework/lib/Zend <-that folder into:
/usr/share/php/Zend <-into this place
Then setup your autoloader and Robert is your mothers brother...
Zend/Gdata.php line 124 is like this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’)
Change that to this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’, $useObjectMapping = true)

Including a php file in Joomla! 1.5 that calls another php file

I would like to include a PHP program into a Joomla! article, this program calls different PHP files that are used to display what I want, I have tried to install different Plugins such as Jumi, directPHP and others, but I keep getting the following error:
Application raised an exception class EDatabaseError with message 'Cannot connect to database server:mysql error: [0: Connection error to server '' with user ''] in CONNECT(, '', '**', )
'
The program runs fine Standalone, however it does not work when I'm running it on Joomla.
The connection parameters are obtained from an include "config.php" but it seems that they won't get the includes from the included PHP file.
Also when I try to include a menu I have made, which works standalone, redirects me to the index.php of Joomla! root dir.
Thanks.
I've done things similar to this, but have had to install a couple of extensions to get them to work.
First, i use the jce WYSIWYG.
then installed place anywhere (which lets you place modules inside articles)
create a new module, type=Custom HTML
code your php there...
I know this isn't exactly what you're describing, but it's the closest i've come in my experience.
If it doesn't work right away, be sure to check for the settings withing the JCE WYSIWYG so it's not breaking your php.
hope this helps!
Try to use 'Flexi Custom Code' extension is a good one
check it: http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/15251
Its a module extension which you can use with 'module anywhere' to place in the 'content area'(article). For calling different php file you can use the php include or required once code
Please feel free to ask if any doubts are there....implementing this

Categories