Run Laravel phpMyAdmin via php artisan serve - laravel

I have a Laravel project running with php artisan serve (no Apache or Nginx) on:
http://localhost:8000/
I have then ran this successfully
composer require phpmyadmin/phpmyadmin
My question is, what additions to Laravel's routing etc. must I do to run the following?
http://localhost:8000/phpmyadmin

Though I haven't found a specific way to have
http://localhost:8000/phpmyadmin
working through Laravel as part of php artisan serve, there is a simple solution that works just fine using PHP's native server instead, assuming you have mysql installed as localhost:
composer create-project phpmyadmin/phpmyadmin
cd phpmyadmin
ls -la #files look like classic phpMyAdmin, note however `vendor` folder in place along with package.json
php -S http://localhost:7000 #and you should be able to see and log in!
This does everything I need it to do. If you want to install phpMyAdmin through an actual webserver like Apache that runs always, you're better off doing something like apt-get [or yum] install phpmyadmin and then you'll have a directory override from Apache running:
http://www.mylaravelapp.com/phpmyadmin

Related

Pulling updates from Git on running project

I have a laravel app deployed on an apache2 server in an ubuntu VM.
It took an awful lot of time to set up, but I would like to make some more changes to the website, e.g. now I added a footer.
Is it safe / possible to just pull in the repository so the updates get installed on the project and then restart apache?
I did google but haven't found anything specific, hence why I am asking here.
Since it took so long to setup I am scared that I break something.
Make sure that the file permissions and ownership is correct. If the files are owned by www-data, and you git pull with your own user, and a new file is created, the new file will be owned by your own user instead of www-data. It's possible to create a git hook that will chown file files for you, but you might as well just do it in your own script after pulling the changes (e.g. chown -R www-data). You can also use sudo to run the git operations as the www-data user, e.g. sudo -u www-data git pull --ff-only.
Additionally, make sure you use git pull --ff-only. --ff-only will refuse to merge if for some reason the repository on the server and in the upstream differ due to conflicts (e.g. a force push). This will prevent git pull from creating merge conflict markers in files, which will probably break your code with syntax errors.
It may be safer to move your git repository into a different folder, do the git operations there, then fix the file permissions etc. and then rsync or otherwise overwrite the files in the directory which Apache is using.
As for Laravel, you'll want to follow the deployment steps outlined in the documentation.
composer install --no-interaction --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache
The :cache commands clear existing caches and re-cache the configuration files, route lists, and compiled Blade templates. If you're previously used the cache commands, you'll need to run these or your new code changes related to configs, routes and views won't take effect. If you haven't previously used these, you probably won't need to use them.
You may also need to run php artisan migrate if you have new database migrations. You may also need to run npm install and npm run prod or other npm related build commands, if you're using Laravel Mix, for example.
After this, you'll want to finally reload your Apache2 instance (sudo service apache2 reload) to clear the Apache2 opcache (if you are using opcache).
Finally, if you're using queues, you'll need to restart your queue workers. The procedure here differs depending on what you're using to keep the workers alive. For example, if you use supervisor as documented here, you might do sudo supervisorctl restart laravel-worker:*. Do this after all of the previous operations, so that the workers are running on the latest code.
Yes, you can pull your code and run these commands to remove your old version caches.
php artisan view:clear
php artisan route:clear
php artisan cache:clear
php artisan view:cache
php artisan route:cache
you didn't need to restart your apache service.

localhost is unable to load application centos server

Trying to fire up a Laravel api and Nuxt app on the actual server by running
lets say server IP is - 10.66.22.41
npm run dev
php artisan serve --port=8001
This obviously worked on my local environment but since this is in the actual server and I am not too familiar with Centos, is there anything I should be doing different?
When I run npm run serve I get http://localhost:3001/
When I run php artisan serve --port=8001 i get http://127.0.0.1:8001
dumb question:
How should I be accessing this on the browser?
for Nuxt, added your script in package.json
"scripts": {
"dev:host": "nuxt --host 'IP-Address' --port 3001",
}
Run:
dev:host": "nuxt --host 'IP-Address' --port 3001
For Laravel:
php artisan serve --host=IP-Address --port=8001
Quick point though, What Khali should be the best practive but if you want to test or whatever you need to do , this is it.
Well, the artisan serve command, will keep the server running until you close the console, which will terminate the service! It is not an ideal setup... I would recommend that you install a webserver of some sort, and install laravel properly via composer. We cannot see how you installed NPM, or if you installed Apache? etc..
I would recommend to install centos webpanel for a starter:
http://centos-webpanel.com/
Then install composer https://linuxize.com/post/how-to-install-and-use-composer-on-centos-7/
Then install laravel using: https://laravel.com/docs/8.x/installation#installing-laravel
This is your best way to manage and run laravel on centos properly (for beginners), if you have the money for it, you should buy CPanel (https://cpanel.net/pricing/) instead of Centos WebPanel, as it offers more flexibility and features.
Good luck!

Laravel project pages not showing

I have cloned a laravel project from github and when I try to use it on my localhost, all I see is the homepage, which is fully functional, but has bits of content and images missing. Then if I try to go to any other route I get an error saying The requested URL was not found on this server.
For reference I am using MAMP as the web server, I have checked the httpd file and everything seems okay, anyone got a clue what's going on?
Use these commands in order :
cp .env.example .env
composer install
php artisan key:generate
php artisan migrate:fresh --seed
npm install
npm run dev
php artisan serve

Downloaded laravel project hangs on preloader when deployed on localhost

I'm trying to deploy a laravel project I have received onto my localhost but it hangs on the loading page and doesn't load the site.
I received the source code of a laravel project that was coded for me.
The deployed website on the shared hosting works properly, and I can also manipulate the files through my ftp access.
However, I'm trying to deploy the project on my localhost (as well as to migrate to a different shared hosting service).
I tried loading the server on wamp, homestead and with artisan serve, but all methods end up the same - the index.php seems to be loading, but is stuck eternally on the preloading .gif file and doesn't present the site.
the browser debugger is throwing a lot of javascript errors (see attached image)
I assume a have a config problem, but I can't locate it and I am unsure how to even locate & debug the issue.
I tried following these configuration steps:
1. changed .htaccess to generic laravel .htaccess (deleted cpanel related lines)
2. changed the .env to fit my wamp db / homestead db
3. composer install
4. composer update
5. php artisan key:generate
6. php artisan cache:clear
7. php artisan migrate
I also installed laravel-debugbar but it hasn't helped me out of the box, and I'm unsure where I need to try to catch the problem.
If anyone can give me pointers on how to understand my problem better, I would be very thankful.
Thanks in advance!
laravel bug
Double check your .env if all details are correct
Set APP_DEBUG=true in your .env file
Double check if your database exist and have data if you are using a database
Check if your host is added to /etc/hosts
Check if your host is added to apache/nginx config correctly
Try running these commands:
$ rm composer.lock package-lock.json
$ composer install
$ npm install
$ npm run dev
$ php artisan clear-compiled
$ php artisan optimize:clear
$ php artisan package:discover
$ php artisan storage:link
$ php artisan migrate:fresh && php artisan db:seed // optional!
Then clear browser cache to be safe.
Open web inspector to see if you can see any errors.
Open latest laravel log in storage/logs/ folder to debug.
If all fails, install laravel-debugbar and see if you can debug there.

Homestead and Laravel basis understanding

I have some questions about the basis understanding about homestead and laravel.
I have set up my homestead with this guide: https://laravel.com/docs/5.2/homestead and it works ok.
1) But when I vagrant ssh into my box, I can call composer, but I can't call laravel or php artisan. Have I done something wrong/misunderstod something?
2) Do I need to install php and laravel locally, can't I just run it on my VM like i do now?
To call php artisan commands (after you ran vagrant ssh command) you need to have installed Laravel project and you need to be in project's root folder:
cd my-laravel-project
php artisan

Resources