FuelPHP "invalid data source name" error - php

I'm trying to set up a FuelPHP app, and I've run into a puzzling problem. Every time the app tries to connect to the database, I get the following error:
Fuel\Core\Database_Exception [ Error ]: invalid data source name
I've set FUEL_ENV to "stage" in Apache's VirtalHost configuration and the database credentials in fuel/app/config/staging/db.php seem to be correct: I can log in to PhpMyAdmin using the same username and password. I'm stumped as to what else to try - any advice would be much appreciated.
In case it helps, I'm using FuelPHP 1.4 on an Amazon EC2 instance running Ubuntu 12.04 LTS on which I've installed MySQL and PHP via apt-get. I have another app (on another instance) running an older version of FuelPHP (1.2.1) which runs with no problems.
Incidentally, this question is probably closely related to this one, but I'm asking it as a separate question because the problem I'm having is not limited to the command line.

Ok, this has taken far too long to get to the bottom of, but it turns out to be simple to fix: for some reason, in FuelPHP 1.4 the stage environment's config directory is called staging (in previous versions it was stage).
I don't know whether this is a directory naming mistake, or whether this is a new name and something somewhere in FuelPHP hasn't been updated to use it, but I found changing the directory's name to 'stage' fixed the problem.

I had the same issue when running unit tests with FuelPHP's oil utility. If you're running into this issue, it most likely is a configuration issue.
To debug, somewhere in the code that isn't working put something like the following to see what environment FuelPHP is trying to use:
<?php
echo "env: " . Fuel::$env;
exit;
In my case, it showed it was trying to use the 'Test' environment. Since I didn't have a 'test' folder in my app's config folder, it was failing.
In most versions of FuelPHP, however you have the Fuel::$env set in your .htaccess file will work throughout all versions of FuelPHP. However in older versions, you may run into this issue.
You can either edit the bootstrap.php file and manually set the FuelPHP environment how you want, or setup the environment that it's trying to use.

Apache web server: SetEnv FUEL_ENV DEVELOPMENT Hope this helps someone

For those of you who none of this worked make sure of two things
there are multiple db.php files /fuel/app/config/development/db.php. check environment as #Chad Hutchins mentioned and double check the username and password is correct
Make sure /var/mysql/mysql.sock exists. In my case I was using /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock so i needed to create a symlink. Followed the instructions here
Hope that helps someone

Related

EasyPHP starting error after trying to change PHP

I have been using EasyPHP-12.1 for some years now but, foolishly, tried to add a different version of PHP. (I had backed up the www files but not the whole installation). I added a new version (5.6.21) to the PHP folder, selected it in the admin but it didn't work. Now the server doesn't start. It comes up with the error:
Error in Apache configuration file: AH00526: Syntax error on line 185
of C:/Server/EasyPHP/apache/conf/httpd.conf: invalid command "PHPIniDir",
perhaps misspelled or defined by a module not included
in the server configuration.
I would like to go back to the original PHP (5.4.6) or, at least, reinstall the program and copy the MySQL databases to the new installation. As I said, I have copies of all the working php pages - it's the databases that I am worried about losing.
I hope someone can get me up and running again.
I seemed to have managed to get it all working again. I found an earlier dated backup in the conf folder, renamed it and restarted. Phew!
(Made sure I am backing up all the databases and EasyPHP folder now.)

which is the environment variables route for cakephp 3?

I recently installed a cakephp with composer to learn about framework use, and trying the bookmarks tutorial, but I get stucked in the checking your installation where you have to open the command line AKA cmd, and writing bin\cake.
It replies back: the system cannot find the path specified.
I've seen some information about how to set up the path variables but I'm guessing it's for version 2+ because apparently the cakephp 3 doesn't have a LIB folder like such:
YOUR_CAKE_DIR/lib/Cake/Console/
Any ideas on how to fix this?
Thanks
best regards!
***************UPDATE**********************
well, I've finally fixed the problem, the path I used for the cakePHP 3 instalation was:
c:\xampp\htdocs\caketest\bin
so I assume that If you aren't using xampp, it should point at the end to: cakeinstallation\bin...
my problem was that I always typed bin\cake but actually all I had to do was type only:
cake
you can read more information in here
bin\cake shouldn't require any special path settings other than being in the correct directory. However, you should make sure that php-cli is on your system's PATH. Depending on how you install PHP it could be in any number of places, but if php -v doesn't output the version of PHP you installed, you'll need to find where your installer put PHP and then setup the PATH environment variable.
With your example, AFAI remember the working directory they were executing cake binary was the parent of "bin" folder, in your case "caketest". I am talking without trying it (I dont have an environment close) you should use:
c:\xampp\htdocs\caketest> "bin/cake"
Watch the quotes. I think they are the main reason of that "the system cannot find the path specified."
I am supossing you are under windows (I saw xampp written in your post) and probably the xampp installation has already added the php folder in the PATH environment variable.

On MAMP can I send php errors to a "per-test-site log"? Or must all errors go to MAMP/logs/php_error.log

Since I have a number of test-sites running in MAMP/htdocs, do all of the errors for all test-sites have to go to the single php_error.log? Can I change this? (I know I can change the log location in php.ini, but I see no way to "divide it up")
The trouble comes from installing "fire_log" logging Spark on one of my CodeIgniter test sites and it seems to want to look for log files relative to the Codeigniter Install. That's what I'm thinking anyway, since it is not finding my logs.
I think it wants to see MAMP/CI_test_site/logs/php_error.log
And I've obviously got
/MAMP
/logs
php_error.log
/htdocs
/CI_test_site
/..folders
/Other_site
/DIfferent_site
So do I have any control over this in MAMP?
You should be able to set it on a per project basis from your code, if that's an option:
ini_set("error_log","/path/to/error.log");

Symfony project is not work on local pc

I have this trouble: i copy symfony project files on my pc, after that change paths and db settings, and it still not working, even dont tell about errors! Maybe there is some specific actions for setting up symhony on another server?
Almost the same problem How to configure symfony project in local server? but when i try execute "php symfony" it prints "no such file or directory"
There are no any php errors at all.
Using Fedora 15 OS, and apache. php work in command line, symfony is not working. I tried to find out what is happening - inside Controller.class some error, when it use processObjects method, it take 11 objects, and after first of them (header.object.php) it stops.
The white screen generally means symfony can't write to cache and/or log dir, check on apache error logs to see details.
if 'php symfony' on command line throws no such file or directory could mean php is not in your system path.
Please add more information to get answers
myabe, as said below is a permission problem of the caché and log files. Check if they are writable. Good Luck!

PHP CodeIgniter 404 on deploy

Oooops I did it again.
My site worked perfectly locally
My development machine is a windows WAMP2 setup
My server is a CentOS 5.5 APACHE 2.2 PHP5 seup
I'm getting a 404 on the codeigniter site that I've deployed, and I really can't make out what's wrong, so please help me find the error.
It's the root url. I haven't set up dns so it's just the ip address of the server. It was showing the standard apache page before I uploaded codeigniter. I've looked over the config file, and it looks ok. Could it be a file permissions error? i have set chmod o+rw in the whole /var/www/html dir. the error_log in the httpd shows nothing
I've tried testing if it was the mod_rewrite module, but I created a test directory with a .htaccess file with RewriteEngine ON that didn't give me an error, so that can't be it.
In codeigniter I've set the log_threshold to 4 in the config, but I don't get any log messages, so I can't really make out if it's a pre-> codeigniter error, but I really don't think it is, as it's loading my Error view, still Why isn't there any log being written, what's it about?
Any help would be extremely appreciated as I'm running on fumes to get this working...
Update
Thanks to #jondavidjohn I have discovered that hitting the controller directly IE:
http://addr/index.php/GeoController/markers/
Will provide me with a controller specific error saying:
unable to locate your model "modelname"
SOLVED
Thanks to #jondavidjohn, and #timdream for giving me the clues to solve this one. It was a naming problem, I had filenames that were camelcased, and they can only be small from what I understand now, so the ROUTE was innefective in that it lead to Site, but should've lead to site although I had a Site.php I had to change it and the route to site.php
make sure you have the correct settings in system/application/config/config.php.. pay special attention to
$config['base_url'] = "http://www.example.com";
Make sure you are putting in the root domain of your site, also check your routing config and make sure you have the correct default controller set in system/application/config/routes.php
I recently started using a fresh install of codeignitor 3.0 and had no problems on my dev server (Windows) then when I moved to my live server (Linux) I started getting a 404 error.
The reason for this is that in 3.0 you are meant to capitalise the first letter of your controllers/models and also the file name.
e.g.
class Test_model extends CI_Model {
Test_model.php
Hope this helps some people who end up here!
For reference:
http://www.codeigniter.com/userguide3/installation/upgrade_300.html
$config['uri_protocol'] could also play a part. It's default to AUTO, which looks for environment variable that contains the actual URL automatically.
I had a web app that fails when I switch to php-cgi from mod_php for my server. Changing the config to REQUEST_URI solves the issue. I found the valve by digging phpinfo() outputs, you could try to do that.
My first bet is that you were developing this and modified the .htaccess file.
HOWEVER, if you went from a Windows -> Linux system change (dev on Win, prod on nix) then you have to keep the Controller names in mind, if a file on windows was "Home.php", and you used "home.php" in the config as your default route, then it will fail.. as there is no "home.php" file.
Home.php != home.php
Linux is case sensitive. Check that out, it might be a simple thing but could cause snags.
Again I am just guessing due to lack of details.

Categories