Database connection error using terminal for advanced module

edited February 2013 in Bug Reports
Not sure if this is a bug or a settings issue. I'm using the latest 1.0 of FuelCMS on a mac with OS X 10.8.2. Using terminal, I cd to my install folder and enter the following in terminal:
sudo php index.php fuel/generate/advanced/ modulename
I get the following error even though my db settings are correct in application/config/database.php (the site works just fine)
<div id="error_db"> <h1>A Database Error Occurred</h1> <p>Unable to connect to your database server using the provided settings.</p><p>Filename: /Applications/MAMP/htdocs/fuelcms1.0/fuel/modules/fuel/core/Loader.php</p><p>Line Number: 134</p></div>Carvels-MacBook-Pro-2:fCarvels-MaCarvels-MaCarvels-MaCarvels-CarvelCarvelCaCaCaCaCaCaCarvCarvCarvCarvelCarvels-CarvCarvC
Line 134 of Loader.php is where the $db obj is supposed to be defined in the database function:
$db = DB($params, $active_record);
/** Load the database drivers **/ public function database($params = '', $return = FALSE, $active_record = NULL) { if (class_exists('CI_DB', FALSE) AND $return == FALSE AND $active_record == NULL) return; require_once BASEPATH.'database/DB'.EXT; $db = DB($params, $active_record); // this is line 134 // <!-- FUEL $my_driver = config_item('subclass_prefix').'DB_'.$db->dbdriver.'_driver'; $my_driver_file = APPPATH.'core/'.$my_driver.EXT; if (file_exists($my_driver_file)) { require_once($my_driver_file); $db = new $my_driver(get_object_vars($db)); } if ($return === TRUE) { return $db; } // return DB($params, $active_record); // FUEL --> CI::$APP->db = ''; //CI::$APP->db = DB($params, $active_record); CI::$APP->db = $db; $this->_ci_assign_to_models(); return CI::$APP->db; }
Btw, $active_record = TRUE in application/config/database.php
Is this a bug or do I have something set incorrectly?

Comments

  • edited 5:08PM
    Does the $params array have the appropriate settings if you var_dump it? If so, do you possibly have multiple versions of PHP installed? What is your Apache/PHP/MySQL stack you are using (e.g. MAMP, WAMP, etc)?
  • edited 5:08PM
    var_dump of $params results in undefined and I'm using MAMP Pro.
  • edited February 2013
    Anyone ever had to deal with pointing terminal commands for php and mysql to those installed with MAMP Pro? I've been doing a lot of searching and haven't found a good solution as of yet.
  • edited 5:08PM
    I've ran into an issue where "php" is pointing to the php version that ships with OSX. The solution was to change where the php command points to or use the absolute path. The second red box in this area talks about this potential issue.
    http://www.getfuelcms.com/user_guide/modules/cronjobs
  • edited 5:08PM
    Thanks so much! Got that mystery solved, however, I get an error stating it was unable to create the controller itself...

    Here's what I ran in terminal followed by the output and error:

    php index.php fuel/generate/advanced/ mpghome CREATED * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/assets/css/mpghome.css * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/assets/images/ico_cog.png * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/assets/js/MpghomeController.js * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/assets/cache/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/config/mpghome.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/config/mpghome_constants.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/config/mpghome_routes.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/helpers/mpghome_helper.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/libraries/Fuel_mpghome.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/language/english/mpghome_lang.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/models/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/tests/sql/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/views/_admin/mpghome.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/views/_blocks/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/views/_docs/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/views/_layouts/ ERRORS * Could not create file controllers/{module}.php * Could not create file /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mpghome/controllers/mpghome.php
    Ever seen that before? It created the entire advanced module directory structure with all the necessary files except the controller.
  • edited February 2013
    I actually saw that earlier today and pushed a fix. It's looking for a template file of {module}_module.php instead of {module).php.
    https://github.com/daylightstudio/FUEL-CMS/commit/af54a39df1c039e6528214397a2badd9f72ccef3
  • edited 5:08PM
    Thanks again! Although now it's having trouble creating a view:

    php index.php fuel/generate/advanced/ mydashboard CREATED * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/assets/css/mydashboard.css * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/assets/images/ico_cog.png * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/assets/js/MydashboardController.js * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/assets/cache/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/config/mydashboard.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/config/mydashboard_constants.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/config/mydashboard_routes.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/controllers/mydashboard_module.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/helpers/mydashboard_helper.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/libraries/Fuel_mydashboard.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/language/english/mydashboard_lang.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/models/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/tests/sql/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/views/_admin/mydashboard.php * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/views/_blocks/ * /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/views/_layouts/ ERRORS * Could not create file views/_docs/index.php * Could not create file /Applications/MAMP/htdocs/fuelcms1.0/fuel/application/../modules/mydashboard/views/_docs/index.php
    I also noticed you pushed a fix to the user_guide and I can see the general docs here:
    /fuel/tools/user_guide/modules
    But clicking any of the links at the top of that page: Simple Modules, Creating Simple, Modules Tutorial, etc., results in this error:
    An Error Was Encountered
    Unable to locate the file: _docs/modules.php
    Thought you'd want to know that. A lot to keep up with!
  • edited 5:08PM
    Thanks for the heads up. Both issues should be fixed now. It will require an update from the user_guide module to fix the documentation. The generation error should be fixed with an update from the FUEL module.
  • edited 5:08PM
    Thanks! I might have done this the wrong way but I deleted the user_guide module directory in order to reinstall. Then in terminal, from the root directory, I entered this:
    php index.php fuel/installer/add_git_submodule git://github.com/daylightstudio/FUEL-CMS-User-Guide-Module.git user_guide
    That produced the following message and resulted in stopping the installation:
    'fuel/modules/user_guide' already exists in the index
    I bet I can name it something else, like - userguide - instead of 'user_guide' and it would work:
    php index.php fuel/installer/add_git_submodule git://github.com/daylightstudio/FUEL-CMS-User-Guide-Module.git userguide
    and I know I could just download and copy the contents from github (which I'll do right now) but thought I'd give you an opportunity to tell me and some other knucklehead out there the proper way to uninstall and install a module.
    Thanks again!
  • edited 5:08PM
    First run the following:
    php index.php fuel/installer/uninstall user_guide

    This will remove any db tables, permissions, and remove it from MY_fuel.php $config['modules_allowed'] array. It will not however delete the folder (you can do that manually).

    Then run:
    php index.php fuel/installer/add_git_submodule git://github.com/daylightstudio/FUEL-CMS-User-Guide-Module.git user_guide
  • edited 5:08PM
    Cool. Thanks so much.
Sign In or Register to comment.