Commit b45bbb8b authored by Shengjie Yang's avatar Shengjie Yang
Browse files

Setup Laravel

parents
Go see the [official documentation](https://laravel.com/docs/7.x/installation) first.
[How to Deploy Laravel Project with Apache on Ubuntu](https://www.interserver.net/tips/kb/deploy-laravel-project-apache-ubuntu/)
[Storage folder with permissions 777 but gives error : Failed to open stream Permission Denied](https://laracasts.com/discuss/channels/laravel/storage-folder-with-permissions-777-but-gives-error-failed-to-open-stream-permission-denied)
[How to create virtual hosts on Apache (httpd) on CentOs 7](https://www.youtube.com/watch?v=O30qTFIr7Uw)
[How To Set Up mod_rewrite for Apache on CentOS 7](https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-centos-7)
## Common commands
```angular2html
php artisan cache:clear
php artisan view:clear
php artisan config:clear
php artisan route:clear
php artisan make:model Feedback
php artisan make:model Model/Quickdemo
php artisan make:controller MasterPlatformController
php artisan make:command ExecR
php artisan make:controller ArchiveController
// Exception: No application encryption key has been specified
php artisan key:generate
php artisan serve
```
## Server Requirements
Laravel 7.x or 6.x requires PHP >= 7.2.5
[How to install or upgrade to PHP 7 on CentOS 7 Linux Server](https://linuxconfig.org/how-to-install-or-upgrade-to-php-7-on-centos-linux-server)
## Install composer
- Go to https://getcomposer.org/download/ and follow the instruction to install composer
- `mv composer.phar /usr/local/bin/composer`
- `vi ~/.bash_profile (OR vi ~/.profile)`
- INSERT `export PATH="~/.composer/vendor/bin:$PATH"`
Then execute `composer create-project --prefer-dist laravel/laravel APP_NAME` and it will create a folder named 'APP_NAME'
## How to update the dependencies installed by composer in Laravel
When you run composer update, composer generates a file called composer.lock which lists all your packages and the currently installed versions. This allows you to later run composer install, which will install the packages listed in that file, recreating the environment that you were last using.
It appears from your log that some of the versions of packages that are listed in your composer.lock file are no longer available. Thus, when you run composer install, it complains and fails. This is usually no big deal - just run composer update and it will attempt to build a set of packages that work together and write a new composer.lock file.
However, you're running into a different problem. It appears that, in your composer.json file, the original developer has added some pre- or post- update actions that are failing, specifically a php artisan migrate command. This can be avoided by running the following: composer update --no-scripts
This will run the composer update but will skip over the scripts added to the file. You should be able to successfully run the update this way.
However, this does not solve the problem long-term. There are two problems:
1. A migration is for database changes, not random stuff like compiling assets. Go through the migrations and remove that code from there.
2. Assets should not be compiled each time you run composer update. Remove that step from the composer.json file.
From what I've read, best practice seems to be compiling assets on an as-needed basis during development (ie. when you're making changes to your LESS files - ideally using a tool like gulp.js) and before deployment.
## Run Laravel without database
```
touch database/database.sqlite
vi .env
// Configure the setting as below
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment