PhpStorm does not recognize PHP built in functions like count(), urldecode(), str_replace() etc. So many annoying warnings shows on each file & auto_complete does not work.
PhpStorm v2020.3
I've tried Invalidate caches / restart, deleting PhpStorm cache folder and also disabled all 3rd party plugins. But this problem exists yet.
Any suggestion would be appreciated.
I found the reason. PhpStorm Php interpreter did not set correctly. After set interpreter and delete manually "caches" & "index" folders and restart Phpstorm it fixed successfully!
C:\Users{my_user}\AppData\Local\JetBrains\PhpStorm2020.3\caches
C:\Users{my_user}\AppData\Local\JetBrains\PhpStorm2020.3\index
Related
Attempting to run a form of PHP linting from the command line, daily.
I've tried SonarLint - lovely in PhpStorm, but sadly they've apparently stopped supporting command line commands.
I tried to get PHPLint and php -l but I'm no php guru and was struggling with composer files.
Finally I looked at PhpStorm inspect - I can get it to create a directory of 99 types of errors, it seems, but then I'd have to either write a tool to grep the files and look /count errors, warnings to see if they're going up / down daily, or check it in the IDE, neither of which are particularly appealing.
There must be a tool that produces a nice simple output that I can incorporate as part of a build pipeline, graphing errors/warnings either daily or after each build?
Try PHPStan (PHP Static Analysis Tool), which supports CLI execution. This is also installed with composer (which is pretty much the default); most PHP IDE support composer out-of-the-box. Likely you won't find that many packages that won't be installed alike that, unless manually dropping them into an include path (this just won't give you the auto-loader capabilities).
You actually can run PhpStorm inspections from command line: https://www.jetbrains.com/help/phpstorm/command-line-code-inspector.html
I've been encountering a slew of issues with a fresh install of Laravel on Ubuntu recently but this latest one has me baffled. I was receiving the WSOD with zero errors in apache/php logs or laravel logs, despite having debug set to true and error display in PHP enabled. I updated the index.php file in public to add a die("Test"); line just to see if that was at least working.
It was, which was great - Test displayed on the site. However, now it won't go away. I've tried updating the text to something else, completely removing the line, etc., artisan cache-clear, composer cache clear and dump-autoload, and I've cleared out any cached items in the storage folders. I've cleared my personal cache and tried different browsers, also, so it's not a personal cache issue. I also tried restarting apache.
All of my chmod permissions should be correct at this point (bootstrap/cache is 755, all of the storage and subfolders are 755). I have had laravel write to the log for another issue (from CLI - a test I did just to make sure permissions were working) so that shouldn't be the problem.
I have this working perfectly fine in laragon on my local Windows machine but have had nothing but issues getting this guy up and running on this Ubuntu server. I have another prod instance of laravel that never gave me this much trouble, either, on another Ubuntu server (and usually it was just a permissions issue). Really not sure what to do at this point or what information might be useful. Hoping that someone else has run into something similar and can shed some light....
what kind of error show's the file /var/log/apache2/error_log?
what is the content of your laravel file storage/logs/laravel.logs?
how did you configure the vhost?
did you install laravel with composer?
give us more information please
Turns out the problem lay with the opcache PHP extension. This was enabled on all versions of PHP installed on my prod environment by default and wasn't something I was utilizing on my dev environment. Writing a test to clear opcache resolved this particular problem and I have since disabled the extension, as I was not intending to use it, anyways.
If anyone else runs into this problem and wants to disable, I simply went through WHM Easy Apache 4 and removed the opcache PHP extensions and then edited the php.ini files for all versions of PHP to set any opcache enabled type of flags to 0 (off).
I know this may be a long and general question but I am struggling with it for the past two days and have achieved nothing.
I am a C# .net developer and I use Visual Studio IDE for my development which does all the back-end work for me when creating projects, setting virtual hosts, publishing the project and etc.
Now for some reasons I have to do a project in PHP and I chose PhpStorm as my IDE. I installed XAMPP and the Apache server is working ok, and I set its' php executable as an php interpreter in PhpStorm.
I don't want all my projects to be in xampp/htpdocs so I choose another location (d:\projects\phpStorm\<name of the project>) as my working space when I first created a project.
I installed xdebug using the tutorial it gave me:
Download php_xdebug-2.4.0rc4-5.6-vc11.dll
Move the downloaded file to C:\xampp\php\ext
Edit C:\xampp\php\php.ini and add the line
zend_extension = C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll
Restart the webserver
And I can confirm that it is installed using phpinfo() in a php file located in xampp/htpdocs.
My problem is with the debugging. When I click Run->Run in an opened php file in PhpStorm, it uses a free port and opens the php file with a url like this: localhost:port_number/<name of the project> and everything is ok.
Now I followed this tutorial to configure the xdebug. In step two, when I go to Run->Web Server debug validation, fill the Path to create validation script with d:\projects\phpStorm\<name of the project> and Url to validation script with localhost:port_number/<name of the project> (as mentioned above) and click validate I get this information (and an error in the last line):
Server Name: PhpStorm 10.0.3
Loaded php.ini: C:\xampp\php\php.ini
No debug extension is loaded
Follow this links to configure Xdebug or Zend Debugger. If you have
already configured debug extension in php.ini file check possible
reasons why it was not loaded:
You forgot to reload web server after changes in php.ini file.
You are configuring debug extension in the wrong php.ini (see the
loaded php.ini files below).
There are errors on attempt to load debug extension, e.g. version
incompatibility.
I want to know what should I do?
I really really want to set my projects in another location other than xampp/htpdocs to organize them properly, just like I do it in Visual Studio. So please don't suggest solutions involving me changing my working directory.
Thanks in advance.
P.S.: In JetBrain's tutorial, I see that the xdebug's IDKEY is PHPSTORM whereas mine is my pc's username, it it ok?
I really really want to set my projects in another location other than xampp/htpdocs to organize them properly, just like I do it in Visual Studio. So please don't suggest solutions involving me changing my working directory.
Well you're really going to hate this then, but unfortunately Apache (which is what php runs on) only recognizes htdocs (or public_html, or www, depending on what specific server you are running, but anyhow in your case only htdocs) as a valid directory for php execution. Sooooo...
That doesn't really mean this is hopeless, but you might have to jump through some silly hoops to get it to work this way.
Option 1
You may have some luck creating a symbolic link from .htdocs to your projects folder from the command line:
ln -s C:xampp/htpdocs d:/projects/phpStorm
If you're on windows, this probably won't work. It also likely won't work between drives. It also may not work depending on your Apache configuration in XAAMP.
PROS: If it works, will do exactly what you want.
CONS: Probably won't work, if it does, will require nightmarish levels of config fiddling
Option 2
Use a remote development server, and sync over FTP with your IDE. I'm not super familiar with PhpStorm, but I can pretty easily do this in Netbeans or Eclipse. This is a good option when you need a local archive of a project retained. You might be able to set up an FTP server on your machine and accomplish this, however you are going to wind up with two copies of your project; one in your projects folder and the other in htdocs.
PROS: Your projects stay organized where you want them without much issue.
CONS: File duplication, they will have to be in htdocs anyhow for Apache to run php
Option 3
Accept that the technology is not designed to work this way and just put everything in htdocs where it belongs. Resisting the way technology works because you are used to a different workflow is how design flaws and really bad bugs happen. Use it the way it was meant to work and don't be scared of learning new things.
PROS: No conflicts with the XAAMP stack whatsoever
CONS: You specifically stated you don't want to do it this way, but this is really the best way
Option 4 (Don't do this)
Install PHP as a globally accessible command line utility across your entire system, and consequently get all kinds of crazy viruses and errors that you may not be able to fix ever.
PROS: Minor alleviation of aggravation with foreign workflows
CONS: All of the things. The worst things.
Option 5 (probably not going to work)
Try using VirtualHosts. There's a bunch of caveats with this though. First, doing this between different drives is nearly impossible to configure correctly due to security policies in your operating system that are difficult to overrule. Second, if you're on Windows (I assume you are if you are using XAAMP), you need to do all of the following:
-In apache.conf, you need to enable your hosts file.
-In the vhosts file, you need to create a new vhost.
-In the windows hosts file, you also need to create a host, because for whatever reason windows likes to arbitrarily add redundant steps. On every other OS, this step is not neccessary. Also, you need to run your text editor as administrator to even do this at all.
-Restart apache when it's all set up
-Pray your machine will let you do this between drives (C: -> D:), or not take a million years to enable.
Yes I have tried searching on StackOverflow and Google for my problem. If you read the entire question you will see that I include a lot of links to previous answers that I found using both.
I have been trying to get XDebug working with Version: Juno Service Release 2 of Eclipse for about the past hour and a half and I'm running into a log of issues. I've already solved most of my problems by using stack overflow and Google.
I followed the steps here first to install the debugger.
I made sure that I added the debugger as a zend_extension as mentioned in this post.
Here are the relevant lines from my php.ini file
zend_extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.collect_params=4
xdebug.var_display_max_depth=999
xdebug.dump.POST=*
xdebug.dump.GET=*
xdebug.show_local_vars=1
I made sure that I edited the php.ini file for the 5.3 version of php that comes with MAMP. At this point the debugger would start even though XDebug does show up when I run php -v.
Since I was still having issues I checked the logs just like someone did here. I noticed this error in the logs:
PHP Fatal error: Class 'Model' not found in ...
After checking the documentation for the latest version of CodeIgniter I noticed that all Models have to extend CI_Model and not Model.
I fixed that and the error is no longer being printed to the logs, but now things just don't work. The debugger won't go past the first line when I try to debug a file.
I'm trying to debug my php application as a PHP CLI Application. When I try to debug the application as a PHP Web Application I get an error message that says:
No tab group defined for launch configuration type org.eclipse.php.debug.core.launching.webPageLaunch
After Googling the problem, I came across this post that suggested that you might not be able to do what I'm trying to do. Since the question was first asked in 2009, I decided to try the second suggestion and check for any updates.
After updating all of my Eclipse plugins I was still having the same problem. After searching on SO some more, I saw that this guy just gave up and tried with NetBeans and got everything to work.
Should I just consider the past 1.5 - 2 hours as a sunk cost and just move on to a different IDE?
I also had issues getting XDebug to work with Eclipse and XAMPP. In the end I decided to go with Netbeans and it was a lot smoother getting it setup. I am still using Netbeans to date for all of my PHP development.
Possibility your Php CLI is picking wrong php.ini file ?
Please go to terminal and check which ini file is loaded by :
php --ini
and make sure its desired one.
jerrod.taylor,
I had a lot of issues when starting use PHP,Xdebug and Eclipse. I considered change IDE myself but I liked the challenge and found a lot of help online. I will try to provide you with some tips will help you.
First of all this is the parameters I have in my php.ini:
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9060
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=On
I am using local machine as remote host. Adapt for your world. This configuration works for me with CLI and Web debugging. I am really not sure if some of them is specific for different kinds of debug. So, lets start with all of them.
Now, make sure xdebug is been supported. Run the following command and see if exist something not good.
php -i|grep xdebug
NOw, lets go to Eclipse. In Eclipse preferences add the correspondent PHP executable and make sure the debuger type is Xdebug. This step can be done navigating through Preferences->PHP->PHP Executables. If you add an item, the form you ask you for the following information:
Name : Choose one
Executable Path : the_path_to_php_exe
PHP Ini file : you can leave it blank
SAPI type : CLI
PHP debugger : Xdebug
This step is important. It is how we will tell eclipse the executable to use.
Now, lets add a debug configuration. I have one project called upload in my workspace and exist a file index.php on this project. To create a debug configuration click in new when "PHP CLI Application" is selected. It will be add a new configuration form for you. For my Debug configuration I have the following information:
Tab PHP Script
Run Time PHP
Alternat PHP: (Select the PHP executable you have created above)
PHP File : /upload/index.php
Break Point : Break at first line is selected
This steps should be enough to you solve your issues. Let us know how it was.
My Xdebug works fine when I use eclipses' internal browser but when I use it in an external browser apache crashes.
I am using xampp and on windows 7 64 bit. If someone needs more information let me know.
For some reason if I have the variables tab open in the php debugger in eclipse it crashes apache. So to stop it I just can't have variables tab open while debugging. So this avoids the problem but doesn't fix it. I would like to be able to have this tab. Any suggestions?
It is possible that the XDebug build and type does not match your apache & php build and type...
Apache compiled with VS.NET 2008 (VC9) for 32bit and using PHP as a module would require XDebug: 32bit, VC9, Thread Safe.
http://xdebug.org/download.php
Also, you could test another WAMP package that comes with XDebug (for example WampDeveloper) and if it also does not work for you, it's probably not a build mismatch issue.
Hey I got this working
Eclipse 3.6.1 (because on later versions key shortcut for putting line comment don't work)
Xampp 1.7.4
Xdebug 2.1.2
The trick is to change php from VC6 to VC9 and then it just works correctly.
BTW. It's the variables panel that causes xdebug to crash apache on php VC6.
Remember to get VC9 version of xdebug for new php AND if you put your new php in directory other than
\xampp\php, then on phpinfo(); you'll see that there's no php.ini loaded so just rename old php (co you can swich them from one to other anytime) and put new php in the same directory in which original php was in "\xampp\php" and copy your php.ini (because paths doesn't change). Also remember to obtain any additional php extensions you've been using in VC9 version for new php and put them in "\xampp\php\ext"
I can confirm most of what t0meck said. Except I've moved up to xampp-win32-1.7.7-VC9 which has PHP 5.38. Taking the phpinfo() results from that to Xdebug's custom installation analyzer, it specifies the php_xdebug-2.1.2-5.3-vc9.dll, but the problem isn't entirely eliminated. As I've documented in my 'notes to self' page, the following is working for me.
After following the above procedure, the 'run as' should work on the first try, but the 'debug as' may crash Apache at every attempt. This is an issue that has driven many people to severe distraction. There is an apparent bug exposed using the debug perspective. At the top center of the perspective is a window with two tabs, the variable view and the breakpoint view. Usually, Apache crashes only when the variable view is highlighted, so highlight the breakpoint view instead. Then set a breakpoint on your project. Now, if you are one of the chosen, you will be able to step through the script using the debugger, but when you switch to the variable view it may still crash Apache. What a drag. Repeat the process and the next time you should actually see the variables and the problem will magically go away, until you restart the project. Just repeat the procedure and be satisfied with being one of the lucky ones.
Don't know if this help, I have same kind of issue, but it relate to array depth xdebug >handle in Variables view. And you can change it. Widnow > Preferences > PHP > Debug > >Installed Debug > Xdebug > Configure enlarge the "Max array depth" solved my issue.
http://bugs.xdebug.org/view.php?id=658#c1767
Just set it to 10 or bigger and it should work