PHP define is not working sometimes on some servers - php

I am working on a PHP web app with another developer. We have 3 total different environments:
Configuration 1: Windows XAMPP, PHP 5.3.5
Configuration 2: Turnkey LAMP, PHP 5.3.X (turnkey-lamp-11.2-lucid-x86) - not sure which ver, running from virtualbox on a mac
Configuration 3: production server, hostgator shared running CentOS, php 5.3.9 fastcgi
Configuration 2 sometimes will not recognize the defines that are handled in our settings.php file which is require_once at the top of any page which uses it. The defines work fine on Configuration 1 and 3 always. There was nothing of interest in the apache logs, other than the errors generated as a result of the define being treated as a string.
I've searched for a while and cannot find anything that describes this issue. Configuration 2 is the other developer, and i do not have access to his machine right now. Looking for suggestions on how to track this issue down. I think we are going to try a new instance of the VM, using an upgraded turnkey-lamp, however i'd really like to root cause this.

Ok, so i figured out what was happening... and as expected, it wasn't PHP or defines. The errors reported were accurrate. We use Eclipse as the IDE, and Subclipse for SVN. Configuration 2 uses a VM running from a mac, and we added a command in eclipse to sync when files are saved. Apparently the syncing only was happening for the main public_html directory, and not our other same-level directory which has the include file with the defines in it. Ultimately, i needed to look at the actual VM to notice it was way out of date on that one file, and was missing the define statement, which results in the error, but Eclipse was showing the HEAD revision from SVN, which is why it was so confusing, but simple.
Lesson: Make sure you plugged in the TV before calling the repairman.

Related

Need help in configuring WAMP (phpMyAdmin)

So I have been looking on the net for hours now and I can't solve my problem.
I have wamp installed (WampServer Version 3.1.7 64bit).
I want to open phpMyAdmin through wamp. (I have the phpMyAdmin5.0.2 installed and phpMyAdmin.conf is configured).
I have several php versions installed.(this was done through the process of trying to fix the solution alone).
When I try to open phpMyAdmin I get this error message: [1]: https://i.stack.imgur.com/ZEMaX.png .
I have tried configuring php.ini file (by de-commenting mysqli) it didn't change a thing.
Here's my php.ini file joined in the google drive link: https://drive.google.com/file/d/1fQuVoh5vhRX-MHhYL3zMQ4xNkstO-4Ch/view?usp=sharing .
I have configured extension_dir tp the php/ext folder.
I have similary configured my windows path to the php/ext.
Nothing I try works. Any help is welcome.
Thank you.
Since you're using WAMP, which should include all the pieces you need already working, but also have several PHP versions installed, it sounds like you're installing more than you need which is causing conflicts.
Assume you have no data in your database or web pages that you need to preserve, I suggest removing everything; get rid of WAMP and any extra Apache, PHP, or MySQL/MariaDB installations you have. Clean up (delete or move out of the way) any leftover configuration files, then reinstall WAMP. If you have trouble after installing only WAMP and no other PHP installation, then report back here details of the error. WAMP should come to you working and all ready to go, so if there is a problem, it will be helpful to start from a known base installation without extra configuration files or executable that will cause conflicts.
I'll also point out that the very top of the file you posted states that it's used only for the PHP Command Line Interface, so this is not the configuration file used by anything running through your webserver (like phpMyAdmin or your site). It's a little confusing that there are really two PHP instances (one for the command line and one that runs through the webserver), but in this case you would be looking for the file in wamp/bin/apache/apache2.x.y/bin/php.ini

Debugging php applications on folders different than 'xampp/htpdocs' with PhpStorm

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.

Pear setup on Mac LAMP

Got a LAMP setup (as per Remy Sharp's set up) on OSX Snow Leopard, PHP 5.3
A site I am trying to run locally is built in CodeIgniter and utilises PEAR which until now I have not used locally.
I downloaded it but it seems that my local environment doe snot know where to look for PEAR.
which pear: /usr/bin/pear
which php: /usr/bin/php
my php.ini file has:
include_path=".:/usr/bin/pear
But for some reason I am just getting an error:
Message: require_once(Date.php):
even though Date.php has been installed in Pear
Any thoughts?
Ha! I've played this game across the years on Tiger, Panther, Leopard...
It's a lesson in frustration if you choose to go down this path--whatever you fix could be trashed the next time Apple wants to rename the /etc/httpd direcotry /etc/apache2. Then I just gave up. My advice is to not use the built in Mac Lamp stack, but to turn off Web sharing in the System Preferences and download and install MAMP or Zend server.
MAMP is configured with everything inside the MAMP.app package, mysql, php (with most pear/pecl libs you need), and apache. It also comes with a util to start/stop your servers.
Now....
If you must go down the route of not using something like MAMP/Zend Server, I'm assuming somewhere your include path is being overwritten.
Somewhere before the error, but after the framework is loaded, try this:
echo get_include_path();
See if you're path still is what you set in the INI file. If not, mischief is going on. Usual places to check:
.htaccess file in docroot of site
config files for your framework--they love to overwrite logging and path ini settings!
Somewhere in your code someone is calling set_include_path('/some/path') or ini_set('include_path', '/some/path')

Netbeans and CodeIgniter on Windows and Linux?

I installed a plugin for NB 7.0.1 which enabled CodeIgniter but when I went to create a project using it, I was told I need to specify a PHP interpreter for Netbeans. I tried to do this using the php.exe you get with Xampp but I get a Java null pointer error. I can't seem to fix this but I'm thinking, why do I need an interpreter on Windows when the Linux machine can do that? I have already set this up on the VM.
Any advice from here? Thanks a lot!
I am using NB 7.1.1 and had similar issue with CodeIgniter plugin when creating a new project. NetBeans would complain No PHP Interpreter was defined in Tools->Options->PHP General. It would not enable finish button so a New Project could not be setup.
I just created a dummy batch file called nb_cli.bat and pointed NB to that for the PHP interpreter. I don't plan on executing (or debugging) CodeIgniter CLI code on local machine so that file will likely never get executed.
If you want to debug or run php locally, make sure xammp works OK outside of NetBeans. But if not, this fix should get you by the NetBeans issues.
I have a separate linux server on my local network for development as I don't need apache/php locally when I use multiple machines for dev/testing/etc.
NetBeans should bugfix that by downing that PHP Interpreter message from an Alert preventing project setup to a warning that No PHP interpreter is defined (or found) so CLI testing may not function.
As an alternative, if you have a linux box with NB installed, you can create the New project there and copy the whole folder (including the nbproject folder) to your PC and you should be able to get by having No PHP Interpreter defined.
Hopefully that gets you going with NB and CodeIgniter. If you need additional details, just ask.

Installing PHP, Apache 2.2.10 on Windows Vista

I am trying to get PHP working on my vista home machine but I am getting weird problems. First I had file permission problems for which I disabled Vista's UAC. Now I can't get the PHP interpreter working.
I have made all the necessary changes following some tutorial but I still can't get it working.
Tutorial was located here: http://www.tanguay.info/wamp/installPhp5.php5
Try XAMPP. I use that at home on a Vista machine and it worked nicely after the install.
WAMPServer is also a good option. You can easily enable/disable both PHP extensions and Apache 2 modules. Everything is set up somewhat securely (only local access to the serve), and you get phpMyAdmin already set up.
Only thing I've ever missed is Memcached, but that is fairly easy to set up on your own.
The only problem I have installing PHP and Apache on Vista is that you need to make sure that when you edit the httpd.conf that you are editing it as an admin, otherwise the file is saved in compatibility mode.
To overcome that problem just type notepad++ or whatever in your start menu, right click the item and run as administrator. Then open the file from the app.
You can use FastCGI for IIS 7. I'm using this also and it works perfectly!!
FastCGI
You can try Zend Core
It works on both IIS and Apache (it includes the installation of the Apache)
iis7 is one of the best web servers and especially for php, if you can't get it to work it means you need to google enough, because it isn't logical to blame Vista for php/apache issues

Categories