Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to install existing fuelphp project from repo?
  • How to install existing fuelphp project from repo? My boss just let me update our service site and he want me to import the files from github.com. I already imported it including the database. The very big problem for me here is that I'm very much new about fuelphp and I even got a lot of problems while testing on my own. And now, the repo has fuelphp files and I don't know if how to install or configure it. Can someone please give me steps here? Also, the repository has .mwb file (which is is a database) which make me more confuse on how to run it with the database. Can anyone help me through this step by step? Very much thank you.
  • HarroHarro
    Accepted Answer
    An mwb file is not a database, it's a MySQL workbench file, so it may contain a schema for a database. An indication that  whoever created this application wasn't too knowledgeable, it would have been easier to use migrations to create the database.

    For the rest, it is very difficult to answer without actually knowing what you have and how it is organised. You have the source of a FuelPHP application? what part exactly? Perhaps you can generate a folder tree and post it (http://bin.fuelphp.com) so we can have a look?


  • Ohh I see. Very much thank you about the information about the mwb file. Because when I try to search the extension, it show mysql workbench. This is actually the site, olivecode.com. Also, it has data which needs database and I don't see any database in here.

    Okay, I have the complete source code. It has many folders, how can I use the (http://bin.fuelphp.com) to let you view all the code
    ?
  • I want to know if the repository you have contains the framework as well, or only the application.

    So I need to find out what the folder structure is. Which folders are in the root of your repository? Do you have a "public" and a "fuel" folder? If you have a "fuel" folder, which folders do you have in there? Does the repository root contain a "composer.json" file?

    Do you know for which Fuel version this application is written?
  • Morning Mr. Verton, Okay. Here's the structure.

     ---- fuel
     > app
     > packages
     > vendor
     > .htaccess
     ---- public
     > assets
     > .htaccess
     > index.php
     > web.config
     ---- composer.json
     ---- composer.lock
     ---- composer.phar
     ---- oil
     ---- olivecode.mwb

    when the time I import it from github. I have those files (i didn't include from git which are .git and .settings)

    can you please me tell what to do first, I need to install it right? 
    Also I want to know how to connect it to the database.


  • Also, I want to apologize for posting the same question. And by the way, I'm using windows.
  • Ok, so you're missing the entire framework from your repo. You should have fuel/core, fuel/packages/orm, etc.

    If the application is build on a recent version of Fuel, you can install the framework using composer.

    Go into the application root and type

    php.exe composer.phar install

    (you might have to prefix the exe if it's not in the Windows search path).

    If this creates the fuel/core folder, you should be in business. If not, you might have to install by hand. In this case it might be easier to follow the docs to install a few installation of the framework in a separate directory, and then copy the fuel/core and fuel/packages folders over to your application folder.
  • Thanks, I already found a solution. They same thing you mention on copy the core and packages folder to fuel folder.


    It's now running. My problem now is how to connect the database. 

    It has  "olivecode.mwb". How to use this database so that I can start working with the project with the given database.
  • I have never used MySQL Workbench.

    I guess you have to install that (http://dev.mysql.com/downloads/workbench/), load the mwb file which produces a database schema, then have workbench connect to your mysql server, create the database, and use the schema to generate the tables.

    This is not the Fuel way (the original dev should have used migrations). BTW, are you sure there are no migrations as well (check the migrations folder)?

    And don't forget to configure the app/config/development/db.php (for your local machine) and app/config/production/db.php (for your production server) with the name and credentials of your database.
  • I think it has, Migration folders has a lot of files and the names are related to the database we are using. What to do with this .mwb? I already install mysql workbench and run the .mwb file. 

    When I run the application it is correctly running because it's using the dev site server.

    running:

    return array(
    'default' => array(
    'connection'  => array(
    'dsn'        => 'mysql:host=dev.olivecode.com;dbname=olivecode',
    'username'   => 'olivecode',
    'password'   => 'zHsTtrs5zruP2s4cKZBAN',
    ),
    ),
    );

    but since it's in my local,

    I need to change like this.

    return array(
    'default' => array(
    'connection'  => array(
    'dsn'        => 'mysql:host=localhost;dbname=olivecode',
    'username'   => 'root',
    'password'   => 'trscebu123',
    ),
    ),
    );

    I'm using xampp, my idea is convert mwb to sql file.

  • If you have migrations, it's unlikely you need the mwb file at all, it is perhaps only used for development. Just run the migrations, hopefully that is all you need.

    In your root folder, run

    php.exe oil refine migrate --all

    (again, you might need to add the path to the exe).
  • Thanks, they really gave me the mwb file because I will continue to the development.

    Already did this.

    php.exe oil refine migrate --all

    result is.

    Performed migrations for app: default:
    046_create_grades
    046_create_documents
    046_create_fees
    046_create_emails
    046_add_is_read_to_contactforums
    Already on the latest migration for package:auth.

    But on the migrations folders, it has 50 files. But only that 4 files are shown in the result. It is okay? So now? Nothing to do with the database?


    and how to use the schema to generate the tables?
    What I did is I run the mwb file and forward engineer to create a .sql file. After that, I create database on phpmyadmin and import the file. It's running but showing some errors. 
  • This is not correct.

    Migrations are executed in sequence, based on the sequence number. These all have the same sequence number, so that can cause migrations to be skipped. The files should start with 001 and then count up.

    Migrations are tracked in a config file called 'migrations.php' and in a table called 'migrations'. If either one of them is out of sync, for example because data is copied or files are copied, migrations don't run properly either.

    Again, you don't need the mwb file, you need to fix the migrations. Otherwise you will have the same problem in production when you next deploy the application than you have now setting up your development environment.

    Best thing to do is:
    - empty the database, remove all tables
    - remove the app/config/development/migrations config file
    - make sure there is no migrations file in app/config/development
    - fix the migration sequence numbers (make sure you don't have dependencies!)

  • I understand now how it works. Thanks.

    Already did what you mention there. Files in the migration folder are already in sequence. from 001 to 050.

    And I try again the "php.exe oil refine migrate --all" again. When I visit again the database, it now generate tables but only 4 tables. Also, migrations.php is generated also in app/config/development/ folder. And still have error on my vhost.

    Base table or view not found: 1146 Table 'olivecode.users' doesn't exist with query: "SELECT `t0`.`username` AS `t0_c0`, `t0`.`email` AS `t0_c1`, `t0`.`group_id` AS `t0_c2`, `t0`.`password` AS `t0_c3`, `t0`.`last_login` AS `t0_c4`, `t0`.`previous_login` AS `t0_c5`, `t0`.`login_hash` AS `t0_c6`, `t0`.`user_id` AS `t0_c7`, `t0`.`created_at` AS `t0_c8`, `t0`.`updated_at` AS `t0_c9`, `t0`.`id` AS `t0_c10` FROM `users` AS `t0` WHERE `t0`.`id` = 0 LIMIT 1"

    Also, in the cmd, it's stack in #17.


    #16 C:\xampp\htdocs\olivecode\oil(62): Oil\Command::init(Array)
    #17 {main}

    That's the end.

    What is lacking?




  • That looks like an Auth table that is not generated.

    When you run the migrations, does it say anything about package Auth?
  • No. :'(

    Here's the result.

    -----------------------------------------------------------------------------------------------------------------------------------------

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

    C:\Users\user>cd c:/xampp/htdocs/olivecode

    c:\xampp\htdocs\olivecode>php.exe oil refine migrate --all
    Uncaught exception Fuel\Core\Database_Exception: SQLSTATE[42S02]: Base table or
    view not found: 1146 Table 'olivecode.users' doesn't exist with query: "ALTER TA
    BLE `users`
            ADD `google_account` varchar(255) NOT NULL"
    Callstack:
    #0 C:\xampp\htdocs\olivecode\fuel\core\classes\database\query.php(287): Fuel\Cor
    e\Database_PDO_Connection->query(3, 'ALTER TABLE `us...', false)
    #1 C:\xampp\htdocs\olivecode\fuel\core\classes\dbutil.php(204): Fuel\Core\Databa
    se_Query->execute(NULL)
    #2 C:\xampp\htdocs\olivecode\fuel\core\classes\dbutil.php(148): Fuel\Core\DBUtil
    ::alter_fields('ADD', 'users', Array, NULL)
    #3 C:\xampp\htdocs\olivecode\fuel\app\migrations\004_add_google_account_to_users
    .php(12): Fuel\Core\DBUtil::add_fields('users', Array)
    #4 [internal function]: Fuel\Migrations\Add_google_account_to_users->up()
    #5 C:\xampp\htdocs\olivecode\fuel\core\classes\migrate.php(288): call_user_func(
    Array)
    #6 C:\xampp\htdocs\olivecode\fuel\core\classes\migrate.php(141): Fuel\Core\Migra
    te::run(Array, 'default', 'app', 'up')
    #7 C:\xampp\htdocs\olivecode\fuel\core\classes\migrate.php(156): Fuel\Core\Migra
    te::version(NULL, 'default', 'app', false)
    #8 C:\xampp\htdocs\olivecode\fuel\core\tasks\migrate.php(223): Fuel\Core\Migrate
    ::latest('default', 'app', false)
    #9 C:\xampp\htdocs\olivecode\fuel\core\tasks\migrate.php(151): Fuel\Tasks\Migrat
    e::_run('default', 'app')
    #10 C:\xampp\htdocs\olivecode\fuel\core\base.php(457): Fuel\Tasks\Migrate->__cal
    l('run', Array)
    #11 C:\xampp\htdocs\olivecode\fuel\core\base.php(457): Fuel\Tasks\Migrate->run()
  • #12 C:\xampp\htdocs\olivecode\fuel\packages\oil\classes\refine.php(108): call_fu
    el_func_array(Array, Array)
    #13 [internal function]: Oil\Refine::run('migrate', Array)
    #14 C:\xampp\htdocs\olivecode\fuel\packages\oil\classes\command.php(126): call_u
    ser_func('Oil\Refine::run', 'migrate', Array)
    #15 C:\xampp\htdocs\olivecode\oil(61): Oil\Command::init(Array)
    #16 {main}

    Previous exception:
    Uncaught exception PDOException: SQLSTATE[42S02]: Base table or view not found:
    1146 Table 'olivecode.users' doesn't exist
    Callstack:
    #0 C:\xampp\htdocs\olivecode\fuel\core\classes\database\pdo\connection.php(237):
     PDO->query('ALTER TABLE `us...')
    #1 C:\xampp\htdocs\olivecode\fuel\core\classes\database\query.php(287): Fuel\Cor
    e\Database_PDO_Connection->query(3, 'ALTER TABLE `us...', false)
    #2 C:\xampp\htdocs\olivecode\fuel\core\classes\dbutil.php(204): Fuel\Core\Databa
    se_Query->execute(NULL)
    #3 C:\xampp\htdocs\olivecode\fuel\core\classes\dbutil.php(148): Fuel\Core\DBUtil
    ::alter_fields('ADD', 'users', Array, NULL)
    #4 C:\xampp\htdocs\olivecode\fuel\app\migrations\004_add_google_account_to_users
    .php(12): Fuel\Core\DBUtil::add_fields('users', Array)
    #5 [internal function]: Fuel\Migrations\Add_google_account_to_users->up()
    #6 C:\xampp\htdocs\olivecode\fuel\core\classes\migrate.php(288): call_user_func(
    Array)
    #7 C:\xampp\htdocs\olivecode\fuel\core\classes\migrate.php(141): Fuel\Core\Migra
    te::run(Array, 'default', 'app', 'up')
    #8 C:\xampp\htdocs\olivecode\fuel\core\classes\migrate.php(156): Fuel\Core\Migra
    te::version(NULL, 'default', 'app', false)
    #9 C:\xampp\htdocs\olivecode\fuel\core\tasks\migrate.php(223): Fuel\Core\Migrate
    ::latest('default', 'app', false)
    #10 C:\xampp\htdocs\olivecode\fuel\core\tasks\migrate.php(151): Fuel\Tasks\Migra
    te::_run('default', 'app')
    #11 C:\xampp\htdocs\olivecode\fuel\core\base.php(457): Fuel\Tasks\Migrate->__cal
    l('run', Array)
    #12 C:\xampp\htdocs\olivecode\fuel\core\base.php(457): Fuel\Tasks\Migrate->run()

    #13 C:\xampp\htdocs\olivecode\fuel\packages\oil\classes\refine.php(108): call_fu
    el_func_array(Array, Array)
    #14 [internal function]: Oil\Refine::run('migrate', Array)
    #15 C:\xampp\htdocs\olivecode\fuel\packages\oil\classes\command.php(126): call_u
    ser_func('Oil\Refine::run', 'migrate', Array)
    #16 C:\xampp\htdocs\olivecode\oil(61): Oil\Command::init(Array)
    #17 {main}

    c:\xampp\htdocs\olivecode>

    -----------------------------------------------------------------------------------------------------------------------------------------

    When I time I import it from github. Nothing is inside the packages folder. So I install fuelphp locally and copy the packages folder then paste it on the existing. Then it's running. Is it okay?
  • Also, here's the error in the browser when I run it.


    1146!
    Fuel\Core\Database_Exception [ 1146 ]:
    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'olivecode.users' doesn't exist with query: "SELECT `t0`.`username` AS `t0_c0`, `t0`.`email` AS `t0_c1`, `t0`.`group_id` AS `t0_c2`, `t0`.`password` AS `t0_c3`, `t0`.`last_login` AS `t0_c4`, `t0`.`previous_login` AS `t0_c5`, `t0`.`login_hash` AS `t0_c6`, `t0`.`user_id` AS `t0_c7`, `t0`.`created_at` AS `t0_c8`, `t0`.`updated_at` AS `t0_c9`, `t0`.`id` AS `t0_c10` FROM `users` AS `t0` WHERE `t0`.`id` = 0 LIMIT 1"

    COREPATH/classes/database/pdo/connection.php @ line 270

    265                            {
    266                                $error_code = 0;
    267                            }
    268                        }
    269
    270                        throw new \Database_Exception($e->getMessage().' with query: "'.$sql.'"', $error_code, $e);
    271                    }
    272                }
    273
    274                // no more attempts left, bail out
    275                else
    Backtrace

    COREPATH/classes/database/query.php @ line 287
    PKGPATH/orm/classes/query.php @ line 1228
    PKGPATH/orm/classes/query.php @ line 1300
    PKGPATH/auth/classes/auth/login/ormauth.php @ line 196
    PKGPATH/auth/classes/auth/login/ormauth.php @ line 695
    PKGPATH/auth/classes/auth/login/driver.php @ line 80
    PKGPATH/auth/classes/auth.php @ line 203
    PKGPATH/auth/classes/auth.php @ line 74
    COREPATH/classes/autoloader.php @ line 375
    COREPATH/classes/autoloader.php @ line 249
    APPPATH/classes/controller/base.php @ line 14
    COREPATH/classes/request.php @ line 442
    DOCROOT/index.php @ line 53
  • Ah, the error is generated by the migrations too. So your migrations are poorly written, they seem to require an Auth table to be there, but don't check for it.

    You can try running the Auth migrations seperately:

    php.exe oil refine migrate --packages=auth

    and then re-run all:

    php.exe oil refine migrate --all

    If the Auth migrations have run but incorrectly, you can reverse them using

    php.exe oil refine migrate:down --version=0 --packages=auth

    once reversed you can run them again using the first command.
  • THANKS. It's now okay. At first, I did this.

    php.exe oil refine migrate --packages=auth

    and then re-run all:

    php.exe oil refine migrate --all

    But on the migrations.php only shows incorrect information such as 

    0 => '004'
    1 => '005'
    2 => '006'

    So I follow the second step which is the reverse. 

    php.exe oil refine migrate:down --version=0 --packages=auth

    php.exe oil refine migrate --packages=auth

    and then re-run all:

    php.exe oil refine migrate --all

    And it's now okay. Migration folder has 50 files and in migrations.php is up to 49 data inside array. But in my olivecode database, it only has 32 tables. It is okay? I think it's okay now. My local is running now. 

    So how to deploy on dev server? I can't cmd on the server.
  • Migrations can do more than add tables. I assume there are also migrations that alter the schema, for example add of delete columns of existing tables, or convert data.

    As to your last question: that might be a bit of a challenge. Fuel has not been designed for shared webservers where you don't have commandline access. I assume you have to use FTP, and use some tool like phpmysqladmin to access the database?

    I think the best option is to create a second vhost and a second database locally for your staging server, and run that in the staging environment using the supplied .htaccess file.

    You can then deploy locally, run migrations to upgrade the database if needed. Once done, you can create a dump of your local database, and restore it on the staging server, and you can ftp your entire vhost contents to the staging server.

    When you need to push a new version, first take a dump of your server database and restore that locally. Then do you deployment as described above.

    If your staging server is local, you could also have your staging environment connect directly to the database on the staging server, that would save you from having to do dumps and restores.

    And don't forget to add app/config/staging/db.php with the correct credentials for your staging db.
  • Since I already have the database in my local, what if I would just export it and once I upload to development site. I will just import that .sql file on the phpmysqladmin folder on the server?
  • If you don't mind that you get your local test data on the server, than that is an option.
    And for subsequent deployments, this would mean losing all your server data.

    Migrations work incremental, the beauty is that you can make database changes without data loss.
  • Okay. Thank you Mr. Verton. You've help a lot. Godspeed. :) 
  • Afternoon Mr. Verton,

    For the steps you've given to me last week.

    - empty the database, remove all tables
    - remove the app/config/development/migrations config file
    - make sure there is no migrations file in app/config/development
    - fix the migration sequence numbers (make sure you don't have dependencies!)

    Do I need to remove always the 
    app/config/development/migrations.php file if I create different vhost?
  • That depends.

    The state of the database, the contents of the migrations table and the migrations.php config file needs to be in sync. If you create a new vhost and you load a dump of an existing database, you have to make sure the config file matches the contents of that dump.

    Differences in these three might cause unexpected behavior when running migrations.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion