RUN LARAVEL PROJECT MISSING .ENV FILE - laravel

How to run laravel project from github on localhost when .env file is missing in the laravel project?

You can rename the .env.example to .env and then run php artisan
key:generate and it'll function as it should.
If you're using a command line simply type cp .env.example .env and
run the key:generate command.
If you are missing the .env files completely, you may take the .env.example file from: https://github.com/laravel/laravel/blob/master/.env.example
Then simply create a new file named .env within your project. You will still need to run php artisan key:generate once you have created the file.

Copy .env.example
Change the name with .env
Make your own settings in .env file.
After that run "php artisan key:generate"

Related

Laravel vuejs. In vue files data from .env file shows wrong value

guys. I'm working on laravel 8 + Vue 3. I real server .vue files (console.log(process.env.MIX_APP_URL) - for instance) shows wrong values from .env.
I checked my .env file in server:
MIX_APP_URL=https://laravel.process.kz.
But in .vue files it gives me "http://localhost:8888/laravelprocess".
I tried php artisan config:cache, php artisan config:clear, php artisan cache:clear, php artisan key:generate etc. Please, help to find out whats the problem.
If you change the env file you might need to restart serve if its still running.
It might also load additional .env files for instance:
.env # loaded in all cases
.env.local # loaded in all cases, ignored by git
.env.[mode] # only loaded in specified mode
.env.[mode].local # only loaded in specified mode, ignored by git

can't make migration in laravel by php artisan migrate command

when i write this command:
php artisan migrate
Laravel Provides Database migrations which don't work very well for me when i write this command:
php artisan migrate
it always give me this error
Change the .env file from 127.0.0.1 to localhost fixed it.
DB_HOST=localhost
do config:cache after .env file change. php artisan config:cache
Ensure you have an .env file, and that the database related variables within have been set correctly.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password

Laravel : .eav file not created in root

After using below command .env file no created in root
composer create-project --prefer-dist laravel/laravel project
and getting error while accessing url
Whoops, looks like something went wrong.
Is there any wrong with this command or any other setting ?
any idea please share
You should create your .env file using the .env.example file to configure the database and everything else as needed. Be sure to generate a key with the artisan command key:generate as well. By default, laravel uses the configuration files inside the config folder.
Its simple to resolve, just copy .env and copy content from .env.example
or
run bellow command:
cp .env.example .env
You can just make one in a text editor. There's nothing special about them. Just lookup an example of one and make sure you fill in all the necessary env variables.
vim .env
or
nano .env
from your app root and add the following:
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
Here's an online example if you need it.
EDIT
If you're worried about the file permissions, sudo chmod 644 .env should be fine. Make sure you add .env to your .gitignore file if it's not already there. You should never track your environment variables in version control.

Laravel Artisan make command issue

I am trying to make a middleware using artisan php artisan make:middleware AuthorizedUserOnly but I get ErrorException like below.
file_get_contents(/mysite.com/www/local/composer.json) Failed to open stream no such file or directory.
This is my document root.
-local
-Laravel application folders
-artisan
-index.php
-composer.json
.htaccess
I changed my directory structure to work with shared hosting. And It was working fine.
KEY NOTES
Other artisan commands work. Like I tried php artisan route:list & php artisan config:cache & php artisan tinker.
This directory structure works fine.But as the error says that it is trying to find composer.json in local directory while it is on document root.
php artisan make:model command spits the same Exception
What could be the possible issue and solution ?
Solution : I moved my composer.json file to local directory and it worked fine. So new directory structure is
-local
-Laravel Application Folders
-composer.json
-artisan
-index.php
.htaccess
HOW ?
I am not sure about this yet. But this is the possible reason. php artisan make command create some files. So to included these created files into system execute composer dump-autoload. So to run composer it looks for in the same directory where artisan lives which is local directory in my case.
IMPORTANT
I changed laravel default directory structure to successfully run my applicaiton on SHARED HOSTING which laravel DOESNOT RECOMMEND.
We should follow the recommendations made by laravel to avoid any similiar issue. Specially never to mess with default directory structure at least.

Zizaco entrust does not create the entrust.php

Why the file entrust.php is not created when I run this:
php artisan vendor:publish
I'm following this config and this is my composer.json
"zizaco/entrust": "5.2.x-dev"
"You can also publish the configuration for this package to further customize table names and model namespaces.
Just use php artisan vendor:publish and a entrust.php file will be created in your app/config directory."
But the file entrust.php is not created.
What can I do? This is odd.
In the link you provided they say and, if it does not appear, manually copy the /vendor/zizaco/entrust/src/config/config.php file in your config directory and rename it entrust.php.
just try this
add
"zizaco/entrust": "5.2.x-dev" in composer.json
then composer update.
Then in your config/app.php add
Zizaco\Entrust\EntrustServiceProvider::class,
in the providers array and
'Entrust' => Zizaco\Entrust\EntrustFacade::class,
Next try in your terminal to publish and see in your config
php artisan vendor:publish
--provider="Zizaco\Entrust\EntrustServiceProvider"
check link for how to use zizaco
I solved it by running
php artisan config:cache
Before running
php artisan vendor:publish
run this command
php artisan config:cache
then run
php artisan vendor:publish

Resources