How to create a build update in laravel? - php

I want to know there is any way by which we can create a installer or some package for laravel application by which user can simple paste file and deployer will ask for db host and other setting and install application.
Also is there anyway by which we deploy a new build in current application and it will have all new updates which may contains updates in previous table. We want to keep data safe and release updates.

Got help from this answer
Install
To create installer for your application, you can Laravel-Installer package.
This package has following features:
Check For Server Requirements.
Check For Folders Permissions.
Ability to set database information.
.env text editor
.env form wizard
Migrate The Database.
Seed The Tables.
Update
Updating your database mean needs to migrate your database. You can run your migrate command through your application.
Run migration command from anywhere
Artisan::call('migrate');
With using route:
Route::get('/run-migrations', function () {
return Artisan::call('migrate', ["--force"=> true ]);
});

Related

How to reinstall user auth modules in laravel

I inherited a Laravel project in which there doesn't appear to be a app/User.php file or any migration scripts related to the creation of user tables for the database. This project was initially used to create a simple REST API end point to write records to a single table without authentication.
Is there a simple command I can run to re-introduce the Laravel user components? My goal is to install Laravel Passport with OAuth2 support, but it seems to depend on the existence of user modules.
you can follow the instruction in the docs: https://laravel.com/docs/7.x/authentication#introduction
Want to get started fast? Install the laravel/ui Composer package and
run php artisan ui vue --auth in a fresh Laravel application. After
migrating your database, navigate your browser to
http://your-app.test/register or any other URL that is assigned to
your application. These commands will take care of scaffolding your
entire authentication system!

Laravel migration deployment

Just a quick one really
I have an existing Laravel app
I want to use a migration to add some columns to an existing table
So i do the following:
php artisan make:migration add_columns_to_table
Which creates a file in my migrations folder called:
2017_10_25_124938_add_column_to_table.php
And also creates an entry in my migrations table in the database. All good.
I can edit the migration file (adding the columns etc) and run
php artisan migrate
And everything works great
Now - my question is this:
When i come to deploy to live i am presuming I would log onto the live box and run the create migration command again:
php artisan make:migration add_columns_to_table
But this will create a migration with a different name to the one i created / tested locally?
So - do i then need to manually copy the code from my local 2017_10_25_124938_add_column_to_table.php migration file to the one created on the live box?
That seems a bit backwards and fiddly
What is the best way of creating and testing a migration locally and then deploying it to live when the create migration command creates a different named migration file (and DB entry) on the live box?
Or have i got the wrong end of the stick?
The best practice is to keep migration files with the repo. While deploying the application on any environment you have to execute all migrations.
php artisan migrate
This command will run all the migrations which are not already executed in the current environment. Laravel use a table called 'migrations' to keep track of all the migrations it has run.

Laravel artisan migrate deployment production

In my deployment strategy I want to do the following:
Get code from git
Install dependencies via composer (dev requirements as well)
Run tests (phpunit etc)
Install dependencies for production (will remove dev requirements)
Zip
Copy to server
Unzip
Change symlink to current release (leave 2 old releases in case of revert)
At this point can I run php artisan migrate to update the database?
Considerations:
The application cache files are purged (actually they are empty like a fresh install).
Will the migrate query check the schema to know if updates are required?
All in all:
Can I run php artisan migrate safely in production with no previous application cache?
How does the migrate task kow the history of the table and what needs to be done?
When you first run your migrations, Laravel creates a migrations table which helps it to know at what point you are with your migrations.
I suggest doing always a backup, anyway you can update your tables without any issue if you test them locally before applying them in production and, most important, you don't edit the old migrations but instead add new ones to migrate, event to edit existing tables (add/remove columns).
PS: Why would you need to symlink if you use git? I'd just tag a working release.
If you are able to get ssh access to your hosting server, even a sandboxed version to just be able to access your site folder, you may directly deploy using git. Best way to avoid any problem caused by a failing copy of files.

PHP script MYSQL database to migration in laravel 5.1

I have MYSQL database.
How can i convert database to migration on laravel 5.1
Any body have script?
In order to generate migration files based on existing database structure you can use one of available Laravel packages. I've used Xethron/migrations-generator in one of my projects - you can find it here: https://github.com/Xethron/migrations-generator.
There are some small issues running it with Laravel 5.1, but they are easy to solve - you can check the discussion here: https://laracasts.com/discuss/channels/general-discussion/laravel-5-migrations-from-existing-database?page=1 - one entry needs to be added to your composer.json.
Once you have the package properly installed and configured, make sure you have correct database credentials in your database.php config file and then run php artisan migrate:generate and migration files will be generated.

How I can install and configure an existing Laravel Project? (Laravel 4)

I need to install and configure an existing Laravel 4 project.
I tried to do, but when I ran composer update or composer install a lot of issues appear.
I have the database too (with data) so I ran the migration but doesn't work because the console show me an issue about the "table doesn't exist".
Can anyone tell me the complete process to configure the App?.
I mean, what its first, second and so and so because maybe in some step I made a mistake
To install and configure an existing project, you'd typically
Check out its source code
Run composer install
Run php artisan migrate
Check the README for specific instructions on installing 3rd party assets, or any additional steps you'd need to take
If the above creates errors, its either because of something in your environment (installing over an old project?) or some problem with the way the Laravel developer created their project.
To install and configure an existing project, you'd typically check those things first :
You should goto app/config/database.php check file and verify username and password.
After check in Project Folder vendor folder and composer.json file exist then remove it (that remove old configuration now we going to fresh configuration).
Then after back to command prompt and fire command composer update and that download some dependent file download.
Now Run php artisan serve
that tricks work for me last time when I migrate another host.
Carlos, when using an existing DB you'll need to check the migrations table to see which migrations have run successfully. Typically when taking over a laravel project setting up a new db and running the migrations against it is a good idea because you never know what hacks were made to the database outside the migration system. One small change can throw the entire system into a useless state because it's looking for a table or column that doesn't exist or has been modified. If you run the migrations against a bare db you can also figure out which tables were manually created (which could very well be your issue) outside the system and add them in as necessary. Cobbling things together after a previous developer is tedious, hopefully there is decent documentation.
Note that if you are using Git with .gitignore, don't forget to copy .env variables in new location too.

Categories