How to use Laravel custom package, called laravel-users? - laravel

I made a new Laravel 5.8 project and run the
php artisan make:auth
and finished DataBase setup/connection. Now I followed the instructions from "https://github.com/jeremykenedy/laravel-users". After publishing it (4 in instructions), I run "php artisan serve" but it still shows the standard Laravel Welcome with login/register option from Auth. What more files do I need to edit/copy to get the "laravel-users" running/showing?

You've already run the make:auth command. The standard views are already in place (check resources/views/auth).
Either manually copy the correct views and assets from the Laravel-Users package, or discard all the auth scaffolding and run the make:auth command again with the package already installed.

Related

From Local to Live, which files to edit - Laravel

strangely I have never programmed locally, I am a beginner but unfortunately I have always created my little scripts directly live. I am using Laravel with Xampp, but now I would like to put my script online.
My question is, what files do I need to edit to make it effective online? At the moment I edit the .env file locally to connect to the database, but is it the same even if I put it online?
Thanks
Here you can find some basic information: https://laravel.com/docs/7.x/installation and https://laravel.com/docs/7.x/deployment
In general, to have a site in production (Laravel or not) it is better to manage your code with git (through Github, Gilab, etc.)
to have a clean version management (the alternative is to use Ftp trought Cpanel, ...).
If you are a beginner, you can go to https://forge.laravel.com/ which is a portal that greatly facilitates the production of a Laravel project.
Otherwise, a generic hosting is better that has the possibility to connect via ssh, in order to easily execute the commands
(composer install, php artisan, ...).
You can do many optimizations in production (I leave out the ones on the .env file you know):
When you do maintenance on the site it is always best to disable it first(status 503):
php artisan down
Upload the latest version of the code from the git repository:
git pull
Clean the item cache on the server:
php artisan cache:clear
Clean the route cache and recreate it (to do if there is no static code in web.php, but only references to code in the controller):
php artisan route:clear
php artisan route:cache
Clean and optimize the config file (reduces the number of files to be read from ten to one):
php artisan config:clear
php artisan config:cache
Clean up expired passwords and reset tokens (clean up tokens when a user requests a password reset):
php artisan auth:clear-resets
Recreate the framework classes or update the application:
composer dump-autoload or composer install
Activate the site:
php artisan up

Laravel - What steps should one take to make a Laravel app ready for production mode

The scenario is I have developed a Laravel app in my localhost. Everything works fine. Now I need to make it go online. I am just trying to figure out what steps (configuration , security etc.) should I take before I make it go online.
I am listing a few steps:
1) Change in .env file to make the environment point to production mode using APP_ENV=production.
2) Avoide showing errors directly in pages as that would expose the innards of the app. Enable error logging instead.
3) Use caching for faster user experience
4) building a nice 404, not found page
What else should I undertake to turn the app from development mode into production mode ?
Apply changes to .env file:
APP_ENV=production
APP_DEBUG=false
Make sure that you are optimizing Composer's class autoloader map (docs):
composer dump-autoload --optimize
or along install: composer install --optimize-autoloader --no-dev
or during update: composer update --optimize-autoloader
Optimizing Configuration Loading:
php artisan config:cache
Optimizing Route Loading
php artisan route:cache
Compile all of the application's Blade templates:
php artisan view:cache
Cache the framework bootstrap files:
php artisan optimize
(Optional) Compiling assets (docs):
npm run production
(Optional) Generate the encryption keys Laravel Passport needs (docs):
php artisan passport:keys
(Optional) Start Laravel task scheduler by adding the following Cron entry (docs):
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
(Optional) Install, config and start the Supervisor (docs):
(Optional) Create a symbolic link from public/storage to storage/app/public (docs):
php artisan storage:link
Laravel deployment docs: https://laravel.com/docs/master/deployment
Digital Ocean's tutorial: How to Install and Configure Laravel
There are some steps you can check
Install LEMP or LAMP stack.
You can check/add PHP and Dependencies for Laravel
Test Your Site’s Functionality
Optimize Image Size
Google Analytics & SEO addition
Check w3 validation
Page speed optimization
configuration
set app_debug to false
make sure you are setting proper folder permissions
Security
use ssl certificate -> you can do configuration with nginx or apache for the same
redirect all requests to https after setting up ssl
set very strong database password
if your app has api's then use api throttling

Creating Schema automatically using migration in Laravel

Is it possible to create schemas automatically in the database when xampp is turning on? There is no information about it in the Laravel documentation, documentation says only how to do it manually by writing the command php artisan migrate.
Xampp includes a script called apache_startup.bat in the root directory, you can add the following line to it
c:\xampp\php\php.exe -f /path/to/laravel/app/artisan migrate
Then when the apache server starts, it should run that the equivalent of php artisan migrate to setup the database.
You can do php artisan make:migration [migration-name] - other than that, you have to fill the rest yourself.

Laravel Serve command does not respect --env parameter

To be able to run Browser tests directly in my IDE (without using the artisan dusk command), I want to run php artisan serve --env=dusk.local. While it indeed starts the local PHP server, it uses the wrong database. It uses the database specified in .env not the one in .env.dusk.local.
I ran php artisan cache:clear thousands of times, but it doesn't change anything.
Running things like php artisan migrate --env=... works.
Is there a way to achieve my goal without needing to rename my .env.dusk.local file to .env before each test?
This is a bug in Laravel 5.8: https://github.com/laravel/framework/issues/27828
There is currently no solution (other than downgrading to Laravel 5.7).
It has been fixed in the latest release 5.8.7.

Laravel-Php artisan serve url (127.0.0.1:8000) vs localhost/laravelproject/public

I want to access my laravel project.I run php artisan serve and access the 127.0.0.1:8000 in browser.
But i learned that I can also check my project using the localhost/laravelproject/public url whithout running php artisan serve.
Question: What is the point of using php artisan serve?
No point in two different methods like you mentioned run laravel by "php artisan serve" and by "project url" followed by localhost. But advantage of "php artisan serve" is you can run you laravel project without putting in htdocs/www directory i.e servers root directory. You can put laravel project anywhere where you want and run through the artisan command.
I found some information you may find interesting:
https://www.quora.com/How-can-I-use-php-artisan-serve
But in simple words, php artisan serve is an easy way to create a php server and that is what laravel needs to run.
You could do the same with "php -S 8080 (which would start a php web server (single threaded) in the current directory on port 8080)"
Also if you have already a php server running with apache or nginx it would not be necessary any of the commands.
Hope you find this helpful.
The `Serve command is just a shortcut for the PHP Builtin Webserver, something PHP has out of the box, so the point of using it is to start testing your application as fast as you could, you just need to install PHP, Composer and your application is up (if you don't need anything else, of course). But if you already have Nginx installed, there is no point at all, just use it.
It's not wise to use the Builtin Webserver in production.

Resources