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.
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?
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.
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.
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.
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!)
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.
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
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
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.
- 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?
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.