Tuesday, April 23, 2019

Solution To: PHP TimeZone Error


Error Message:
"It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function."
Solution:

1. Edit PHP ini file.
1.1. Find timezone entry  ie ;date.timezone
1.2. Uncomment the entry ie delete the symbol ";"
1.3. Add a time zone name ie date.timezone="Asia/Kuala_Lumpur"

Solution To: HTTP 500 - Internal Server Error


1. If the file .htaccess exists, remove or rename the file into something else and then put it back. See if the problem resolved.

2. Check Apache Error Logs to get some clues. It could be due to Apache Modules not being enabled. For example, check that Mod Rewrite and Mod Headers are enabled.

Wednesday, October 17, 2018

Solution To: Laravel Error No application encryption key has been specified.

.
PROBLEM:

RuntimeException
No application encryption key has been specified.

SOLUTION:


1. If .env does not exist in root folder, .env.example file in the root of your project to .env or create a new .env file.

2. You should not just create empty .env file, but fill it with content of .env.example.

.envfile look like this: (Fill up with required database connection)

APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
.


3. In the terminal go to the project root directory(not public folder) and run

php artisan key:generate

If everything is okay, response in terminal should look like this
Application key [base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=] set successfully.

4. Check that the Application Key is inserted into .env file.

You can just copy key itself and paste it in your .env file as the value to APP_KEY. Result line should looks like this:
APP_KEY=base64:wbvPP9pBOwifnwu84BeKAVzmwM4TLvcVFowLcPAi6nA=

5. In terminal run

php artisan config:cache

.
REFERENCE:
https://stackoverflow.com/questions/44839648/no-application-encryption-key-has-been-specified-new-laravel-app


Solution To: Laravel Error file_get_contents(/var/www/laravel/.env): failed to open stream

.
PROBLEM:

file_get_contents(/var/www/laravel/.env)
: failed to open stream
: No such file or directory”?

SOLUTION:
Probably you missed your .env file in laravel project folder.So make .env.example to .env file. Also give the required database connection.

.envfile look like this: (Fill up with required database connection)

APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
.
REFERENCE:
https://stackoverflow.com/questions/36761778/how-to-resolve-the-error-errorexception-file-get-contents-var-www-laravel-e

Solution To: Laravel Error failed to open stream: Permission denied



PROBLEM:

Laravel Error failed to open stream: Permission denied

SOLUTION:

Most folders should be normal "755" and files, "644"

Laravel requires some folders to be writable for the web server user. You can use these command on *nix based OSs.

Using ACL

// nginx = web server user
// systemuser = your local user which you use to login via ssh
sudo setfacl -Rdm u:nginx:rwx,u:systemuser:rwx storage
sudo setfacl -Rm u:nginx:rwx,u:systemuser:rwx storage

Alternatively, if you don't have ACL

sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache


REFERENCE:
https://laracasts.com/discuss/channels/general-discussion/laravel-framework-file-permission-security
https://stackoverflow.com/questions/30639174/file-permissions-for-laravel-5-and-others

Solution To: Whoops, looks like something went wrong. Laravel 5.0

.
PROBLEM:

I installed Laravel 5.0 properly by cloning in git, and composer install, when I ran it to browser http://localhost/laravel/public/, it says

"Whoops, looks like something went wrong."


SOLUTION:

The error logs are located in storage directory. 

You need to check the error message in order to identify the cause of the error.

Solution To: Laravel 5 Failed opening required bootstrap/../vendor/autoload.php


PROBLEM:
Laravel 5 Failed opening required bootstrap/../vendor/autoload.php

SOLUTION:
...

When the new project created the laravel require to load vendors to autoload the libraries , We need to tell composer to update via command:

composer update

Composer is a dependency manager allows you to delegate responsibility for managing your dependencies to a third party.

In some cases, you need to tell composer to install first via ommand:

composer install 

If this does not solve the problem, make sure the following php modules are installed php-mbstring php-dom

To install this extensions run the following in terminal

sudo apt-get install php-mbstring php-dom

once the installation is complete

try running the command in your project root folder

composer install 

REFERENCE:
https://stackoverflow.com/questions/28468625/laravel-5-failed-opening-required-bootstrap-vendor-autoload-php


Labels