Starting with existing database on Laravel 5 - php

I have been enjoying working on Laravel for a while now, and am planning to move a fairly large project to Laravel 5.
The new project has fairly large database with numerous tables, and it would take considerable amount of time build migrations, models and controllers individually.
Has anybody worked on this before? What is the best way to go about it?
I have used this great extension to generate migrations as of now - but still for a 200+ tables, it would take quite a long time to do the rest.

Try this one:
https://github.com/reliese/laravel
Reliese Laravel is a collection of Laravel Components which aim is to help the development process of Laravel applications by providing some convenient code-generation capabilities.

How about this: http://packalyst.com/packages/package/ignasbernotas/laravel-model-generator
Model generator Laravel 5 model generator for an existing schema.
It plugs into your existing database and generates model class files
based on the existing tables.

For migrating models and controllers just use artisan commands, you can't get around it any easier than that. For the migrations I can suggest trying to use the following package:
Laravel Database Exporter
It will export your existing DB schemas as Laravel migrations. My suggestion is based on the assumption that you are using MySQL as your RDBMS, because the package I suggested only works with that.

Related

Db migrations in zend framework 2

I was using Yii2 framework for a long time. There is a DB migrations in Yii2 (http://www.yiiframework.com/doc-2.0/guide-db-migrations.html). It helps easily change DB structure by console command.
Is there something similar to Yii2 DB migrations in Zend Framework 2?
In Zend Framework 2 there are some possibilities to manage database migrations. First it depends what you are using to interact with the database. If you are using Doctrine you could use https://github.com/MurgaNikolay/DoctrineMigrationsModule.
If you are using Zend\Db instead, you could use this module: https://github.com/vadim-knyzev/ZendDbMigrations (documentation is in russian...).
There are some general modules that help you managing migrations: https://github.com/vgarvardt/ZfSimpleMigrations (the one with the most activity in the repo) or https://github.com/valorin/zf2-phinx-module that is using Phinx under the hood.
If you want to have a look to something really new, go to https://github.com/baleen/migrations, a really nice project that is being developed. This will probably require some work on your end to put the pieces together.

Laravel 5.1 LTS multi tenancy

I am fairly new to laravel, I have a project at hand with multi-tenancy needs. I saw this package https://github.com/laraflock/multi-tenant and I was interested in it until I saw it only allows for a database per tenant. I want to achieve a single database for the whole application separating tenants by ID. I already have my database structured. Is there anyone with an opinion on how best to achieve that with Laravel 5.1? I have seen so much on 4.2 but since I have not tried 4.2, I just skipped.

Laravel Existing Database

I have a database we use on some of our existing websites, sites were built in Yii framework by another developer so no Laravel, I have set up a new project using laravel but am looking for the best way to link up to that database and return the information.
linking to the database is easy enough, just change the database.php file but I am getting really confused with migrations part and how to call it into a webpage.
So what's the simplest way to go about doing this?
Migrations are used to create or modify database structure. Since you already have a database set up, you don't need to use migrations.
To get accustomed with Laravel I strongly suggest watching:
Laracasts - Laravel 5 Fundamentals
I also suggest you go over the entire Laravel Documentation just to get acquainted with all the framework has to offer.

How to handle migrations on two separate laravel projects that use the same database?

Our setup is this:
We have and API that feeds an iOS and an Android app
We have an Admin API that feeds an Admin web app
I'm developing the Admin, my colleague is developing the app API.
They both use the same database, and most of the same tables. Merging them into a single project is not an option as we will deploy to Elastic Beanstalk and the Admin doesn't need to scale, since it will be used by a small number of people.
The issue we ran into is handling migrations, and we've arrived to the following conclusions:
We can't both have our own migrations in our projects, as the versions would not add up
If we keep migrations on only one of the projects (we both have access to both projects), the project without migrations can't be redeployed without redeploying the other one
If we make a 3rd project that only has migrations, we are hosting an application that essentially doesn't do anything
While I can think of hacky ways of fixing this issue, we're looking for a best practices approach.
I would recommend the option of creating the third project that only has migrations. That way, you keep all the migrations in one place and avoid problems of inconsistency, and you decouple the migrations from the deployment of either app. The fact that the app doesn't "do" anything shouldn't matter; you don't need to deploy an extra app, just run the migrations from your deployment server. You don't actually have to create a whole Laravel project just for your migrations; it's fairly simple to use Eloquent outside of Laravel. This article gives an example of using the Eloquent query builder to run migrations outside of Laravel. You could also use a lightweight migrations tool like Phinx, which offers a similar feature set to Laravel's built-in migrations but with minimal dependencies.

Data import and migrate using Doctrine

I need to load data from an old DB into a migrated schema of this DB using Doctrine migration system.
I guess Doctrine might help me in this process.
I tried and lost a few hours using ETL scripts programs, without success.
From my point of view I need to :
Create a DB with the V0 schema
Load the data from the old DB (schema are identical)
Migrate DB to latest version using Doctrine migration
Extract data
Load it in the new DB
WHat do you think of this process?
Do you think it is feasable using Doctrine?
I tried a few searches on Google without success.
I am currently reviewed the features of Doctrine_Core class.
Thanks for your help
Yes, it is possible to migrate data from one database to another using Doctrine.
It sounds like you're trying to do a one-time database revision and migration and that your applications are not currently written using Doctrine. In that scenario, database abstraction has little or no benefit, unless you're also rewriting the applications to use it.
If you have no prior experience using Doctrine then I seriously doubt that writing custom migration classes in it will be easier than doing it with whatever database API you are already experienced using. It makes sense to use the migration classes (some times) if you are already using Doctrine for your development. Otherwise it's another layer and API you don't need.
I'm using Doctrine 1.2, which has some nice features for migrations but also a number of bugs and omissions of expected functionality. Reportedly version 2 improves on this but I haven't used it yet.

Categories