Hi everybody and thanks reading this post,
I'm very enthusiastic about Fuel, it's like you write: a set of the best of other framework.
I'm trying to develop a site to improve my knowledge, but I have some problem with this configuration:
- Windows 7
- EasyPHP
Why using EasyPHP instead of a fresh installation? Because at work we develop some site, under maintenance, that doesn't work with php 5.2, so running different version of EasyPHP i can use different version of PHP.
But now I have some problem with OIL, because it gives me this error, as you wrote in the user-guide:
Error - call to undefined function mysql_connect() in COREPATH/classes/database/mysql/connection.php on line 77
I know that it is a problem with my EasyPHP installation, but how can I use oil features? All my script works perfectly so the question is: there exists a possibilities to use it from browser instead of console?
Thanks guys!
This happens when the PHP commandline utility can't find the database.
This happens quite often when using pre-build environments, MAMP on Mac has the same issue, it's mentioned in the docs. Sometimes it's also caused by the webserver of such an environment using a custom php.ini to start up. When using php from the commandline, this file is not used, leading to all kinds of configuration issues.
Let us know if you find the solution, so we can add it to the documentation.
I don't think this should be mentioned in the docs, it's just part of getting your installation right.
If you loaded up some Fuel code in the browser (which uses the Apache module / CGI) and saw that function mysql_connect() did not exist you'd know exactly what to do, you'd go and make sure you had PHP configured to use the mysql extension.
The command line version of PHP is no different. If it doesn't work, you just need to make it work as part of the requirements of running the framework.
Ok guys, I found a solution to the problem (and I'm very happy for this!)
The problem it's that the installation of EasyPHP doesn't set correctly the php.ini path, so every resource of you installation isn't correctly loaded, because it depends on EasyPHP (that isn't load from the command line).
This is what I did on Windows 7.
** STEP 0 - BEGIN **
First of all you have to add php path to the Environment Variables:
- Go to "Start" (on the bottom-left on the screen)
- Right click on "Computer" link
- Click on "Properties"
- Now go the link on the left "Advanced System Settings"
- Now click on the "Environment Variables" button
- On the "System Variables" list edit variable name "Path" adding you php and mysql installation path. Mine is: PHP path: ";C:\Program Files (x86)\EasyPHP-5.3.6.1\php" MySQL path: ";C:\Program Files (x86)\EasyPHP-5.3.6.1\mysql\bin"
*NOTE: Remember the ";" at the beginning of the string!
Now you can use mysql and php from command line. It's time to resolve the problem
** STEP 1 - FIND THE PROBLEM **
As I said, EasyPHP installs PHP correctly, but ONLY if you run it from web, not from console. If you try to retrieve the list of loading modules, you will not find extension you added to you php.ini file in the EasyPHP path.
1) Open windows console (running cmd.exe)
2) Execute "php -m"
You will not find mysql, this is what causes problems with oil.
** STEP 2 - A NEW PHP.INI FILE **
As I said running php from console don't load our real php.ini file. If you try to retrieve the list of directory in which PHP searchs for php.ini, we will see that it doesn't search in EasyPHP directory:
1) Open windows console (running cmd.exe)
2) Execute "php --ini"
If you have my same problem, you will not see any php.ini file loaded.
What we have to do is to create a php.ini file in a directory in which PHP search for.
1) Go to our "EasyPHP installation directory", under the folder "conf_files". Mine is "C:\Program Files (x86)\EasyPHP-5.3.6.1\conf_files".
2) Copy the "php.ini" files
3) Past it into the directory "C:\Windows"
Now your php.ini file is correctly loaded.
** STEP 3 - SET THE CORRECT PHP PATH **
The last step, setting up the correct path in php.ini file: if you open it you will see all the path like this: "${path}\php" and more. It is because the variable "${path}" is resolved by EasyPHP, but now we are using console, so EasyPHP isn't used.
What we have to do is to modify every path with our PHP path... But there is a problem: the path we use here can't contain any spaces.
It is a problem, because my installation of EasyPHP is like this: "C:\Program Files (x86)\EasyPHP-5.3.6.1" so I HAVE space.
There is a solution for this, named 8.3 filename: in every windows installation we have 2 different way to name a directory:
- Long, like C:\Program Files (x86)\EasyPHP-5.3.6.1
- Short, like C:\PROGRA~2\EasyPHP-5.3.6.1
What we have to do is to set, in php.ini file, only SHORT name.
What you have to do is modify only path with spaces, not all path: in my case I have to modify only "Program Files (x86)".
To do that we will use a console instruction, so let's go:
1) Open windows console (running cmd.exe)
2) Go to the parent directory of the path you have to modify (in my case is "C:\") - use "cd.." to go to the upper directory and "cd {path}" to navigate in a children folder
3) Execute "dir /x" instruction: now you will see a list of short AND long path. Read the path you need (in my case it was "PROGRA~2").
Now we can set up our php.ini file: replace every occurrence of "${path}" with you short path, in my case it was "C:\PROGRA~2\EasyPHP-5.3.6.1".
** STEP 4 - ENJOY IT! **
Finish! Now PHP load the new php.ini files that loads extension from you EasyPHP installation!
I hope that it will help you all.... and that it will be mentioned in documentation
Bye bye!
Don't worry, I did it to help people with my same problem.
I tried it on a different system and a different version of EasyPHP: I have the same problem and I use same solutions.
I know that it's a PHP installation problem, but it is an auto-installation with EasyPHP, so I can't modify it without modify every config file... but in that case it will be better to do a fresh installation of PHP, Apache and MySQL.
It's just a solution, if someone will find a better one I will be happy