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.
Related
I am using Laravel 5.6.
My Current Code deployment process is as follow
Made some changes to file
Commit and push it to branch.
Once everything is perfect merge it to master and pull master branch to code production server(Where my code is).
My Issue
If I have some dependencies which is maintained by composer. I just add it to current branch and made changes to other files.
When I merge it with master and pull it to production server I need to run composer update command manually.
Server gives errors when we try to access it that it dependencies class or service provider not found(As we need to add it to config/app.php in Laravel) When it is updating composer dependencies.
After updating it is working perfectly.
So I want to avoid that 5-10 sec error which comes while updating composer dependencies.
I have two options
Put Application on maintenance mode while updating code. -> I cannot do that.
Every time whenever there is dependencies upload it using two merge. -> I Don't want to do that.
Is there any other best practices solutions to this problem so that we can avoid such errors.
You should never update on the production server, just composer install. You can hook this to your merge git action, accordingly to how you deploy to production (CI/CD, scripting or all manual?). Here documentation for git hooks: https://git-scm.com/docs/githooks
this is for git-hooks post-merge: https://git-scm.com/docs/githooks#_post_merge
The best way to deploy to avoid this problem is that each time you deploy, you do so to a new folder. Then, once the deployment is complete, you switch the folder.
This could be done using a symlink, or similar:
deploys
1551270000
1551280000
live > deploys/1551280000
Then make a new deployment (1551290000):
deploys
1551270000
1551280000
1551290000
live > deploys/1551280000
Then when it’s finished, change the symlink:
deploys
1551270000
1551280000
1551290000
live > deploys/1551290000
This is what Capistrano and others do. I would recommend using a tool like that rather than trying to write your own – this problem has already been solved.
When I merge it with master and pull it to production server I need to run composer update command manually.
No you dont. You should only run
> composer install
on the live server to make sure composers dependancies are up to date with changes.
I've got a real head-scratcher for you! I've been working on a Laravel 5.4 application for quite some time now and up until yesterday I had been able to:
develop on my local machine [still works flawlessly],
push my changes to my BitBucket repo [still okay here],
and would subsequently pull those changes to my shared hosting server (RedHat) [still running smoothly],
I then run my dependency managers (npm and composer) to get the project in place and functional
there is some matter with clearing various caches:
php artisan view:clear
php artisan route:clear
php artisan cache:clear
composer dump-autoload
and finally move my '/public' folder to the web root and update index.php to point back to the 'bootstrap/autoload.php' in main project structure,
I am aware there is likely another or several steps I am missing, but I am unsure what they are...
All that being said, I've attempted to deploy a number of applications using Laravel lately and I always seem to run into the same issue come time to deploy an application to production. I've read 30+ tutorials on the matter and nothing seems to explain the issue why my site isn't working any more.
I've checked the error log file maintained by Apache, it's empty.
Was wondering if it's a permissions issue, doesn't seem to be the case (all folders set to 775 and files set to 664 as specified by various sources and owned by serverName:userName)
Browser console simply shows a 500 server error.
All I see if "Whoops, looks like something went wrong." twice.
There must be some way to show better error details (config debug setting already set to true)
Any suggestions at this point would be beneficial to send me looking in the right direction!
======= UPDATES =======
For the sake of thoroughness, and that this save others from severe headaches, I'll be posting actions taken here.
Following tutorial mentioned by #user123456 (permissions applies)
Generate new key for application
Run php artisan config:clear
Off to the races, answer to come!
You need to ensure you have a working .env file.
Once done, run php artisan key:generate to create a key for your application after which you should clear your application's cache as follows php artisan config:clear
I would never recommend using shared hosting for Laravel application. You will face lots of issues for permissions, composer and external dependencies. Instead, you can use cloud servers like DigitalOcean, Linode, vultr and deploy laravel application on them. If you don't know about linux and creating Stacks you can use Cloudways to deploy laravel.
https://dev.to/rizwan_saquib/deploy-laravel-application-on-cloud-easily-with-cloudways
Five months ago I created a pretty extensive Laravel Blog Management system. I am now at a point where I am looking for a job and would like for potential employers to be able to easily install and run my project to check it out. I want to include instructions in the readme.md on how to get it started but I've just realized that I can't figure out how to run it myself!
Here is the repository: https://github.com/colesam/Laravel-Blog
Here is what I've tried:
git clone git#github.com:colesam/Laravel-Blog.git
composer install
php artisan serve
This copied the repo into my xampp/htdocs directory and ran it. XAMPP is currently running with MySQL and Apache running.
The console responds by telling me it's being served on localhost:8000. Unfortunately I receive an error message on the actual html doc:
What is going wrong with my project and how can I make this as easy as possible for my potential employers / anyone who would like to download and check out my project?
It's really easy actually. Takes about ~5 minutes. Here are the steps:
Clone the project
Create a database
Copy .env.example to .env and set the correct database credentials
Run php artisan key:generate to generate the app key
Run php artisan migrate to create the tables
Run php artisan serve
And you're done.
I've been running a project written in Laravel which has been fun to use.
The setup I use is the vagrant box Homestead configuration so I do the majority of my work on my local machine and push up to the development server once its ready to go. During the installation I had to push up the logs & vendor folder for it to work properly but now I'm at a stage where every commit I do via the command line includes storage/logs/laravel.log which when I then pull down it asks me to stash/commit on the server because they're different.
I've added it to the .gitignore file in the root directory of the project and it looks like this:
/node_modules
/public/storage
/.idea
Homestead.json
Homestead.yaml
/storage/logs/
/vendor/
Vendor doesn't cause me any problems unless I make changes to it so its not much of a bother, its just the logs which will not stop going up. If I use a GUI tool, I can manually tell it not to go up but I want to get it to the point that I can use the terminal to push it up and not worry about logs need stashing on the server.
I believe this is the same for the .env so I imagine a solution will work for both. I have also noticed that PHPStorm have said they're ignored but tracked with git if that helps.
If you take a look at the Laravel repo on GitHub, you'll find the following .gitignore file in the storage directory:
https://github.com/laravel/laravel/blob/master/storage/logs/.gitignore
This comes with the default installation to mark the logs directory as ignored. If you've deleted this by mistake, you should be able to reinstate it and resolve the issue you're having.
Just as importantly though, your workflow isn't following best practice. With respect to "Vendor doesn't cause me and problems unless i make changes to it" - you should never make changes to your vendor directory. This folder is home to third-party packages and plugins, modifying them directly causes multiple issues, chief amongst them:
You can no longer update a modified package without breaking your application.
Other developers won't be able to replicate your installation easily.
In fact, the vendor directory shouldn't be versioned at all. The best way to handle the files within it is using a package manager, like Composer, to do it all for you. This means you can easily switch between different versions of your packages and, by versioning only the composer files, other developers can run composer install or composer update to synchronise their development environment to yours quickly and accurately.
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.