Working Laravel in CPanel but not in localhost without Artisan - php

I've installed in my remote server, via Softaculous, Laravel 8.
In order to access directly to the APP, just like when running php artisan serve in my local machine, in CPanel i defined the document root to the folder Laravel\public.
Everything works exactly as it should! I type the address (ex: myDomain.com) and the App runs perfectly...
However i don't want to being always typing php artisan serve while developing, so i tried to replicate the cpanel struture in my local machine.
To achive thar, i've created a virtualhost in XAMPP httpd-vhosts.conf pointing to the folder Laravel\public, and created the host file in windows system, like always.
When accessing the location in my local machine the first page renders perfectly, but as soon as i make a request for a new view, by example:
Route::get('/posts', function () {
return view('posts.index');
});
I get a "Not Found The requested URL was not found on this server" error! I'm sure is not a coding error because the same code runs flawlessly in remote server.
Which technique is used by cpanel to allow laravel to work directly from \public folder without necessity to initiate anything and how to replicate that in local development machine?

Well...
After much reading, backs and forwards, i believe this behavior depends on the way Apache its served by XAMPP.
So, the solution i adopted was change my local development tool to LARAGON.
Everything worked just fine with a lot of new features that donĀ“t exist in XAMPP.

Related

Having trouble running a backup copy of php on Xampp

I uploaded a php script to a subdomain that I own, for testing and customizing purposes before it goes live (I had planned on moving everything over to the root domain when done).
Someone then suggested that I work on in Xampp instead as it is all locally installed and therefore much faster, etc.
Thing is, I had already customized the script a lot (mostly CSS but also uploaded graphics via the admin panel, etc) while it was up live on the web host, so I would like to run a copy of the most up-to-date version of it in Xampp and continue customizing it from there.
I downloaded a copy of all my files by FTP into htdocs > Test folder. I also downloaded a copy of the database via phpmyadmin and imported it via phpmyadmin into my localhost.
The big problem I have is when I try to access the scritp via localhost, the url immediately reverts back to the live url. How do I set it to link to the local host copy instead?
Thanks.
Based on AbraCadaver's suggestion, I found the answer lied in changing the URL parameters in config.php
Thanks

Failing loading js files

I'm using Joomla mainly because I'm trying CiviCRM. Joomla is quite easy to install and it runs well on my server.
I've installed CiviCRM, which works well on local server, but CiviCRM app doesn't work well from outside the local server.
I can see that Firefox doesn't load correctly some js files, the location indicates my internal server address instead of the alias.
How do I solve this?
I solve this problem by manually updating the civicrm.settings and changing some values that were pointing localhost instead of my server URL.

How to unbind the php built-in server from a directory?

I created a local WordPress site and in XAMPP set it up with Virtual Hosts so the address test-wp.dev was the home adress. All was working fine and then for some reason I decided to turn off apache, leave mysql on and try the build in server.
So I navigated to C:/xampp/htdocs/test/wordpress/ and ran php -S localhost:8080
It worked fine. However, today I went to go back to test-wp.dev using the Apache server and it keeps redirecting to localhost:8080. I don't want to use the built in server now. I want Apache.
Where do I "unbind this" or free up that port or whatever. I don't want to have to run the built in server for that folder anymore.
Thanks.
Windows 7
PHP 5.6

XAMPP-Project not working on different computers

So, I Have REST URL to register like this :
http://localhost:8080/task_manager/v1/register
And then, I try the URL in Google Chrome Advanced Rest Client.
Everything goes smoothly.
And now I decided to test the URL on another computer.
So I copy paste the file to another computer and test the URL once again.
But the result is I got 404 ERROR, Object not found.
Did I hit something wrong ?
I copy all the file correctly.
This is weird.
UPDATE : I use all the folder which contains all the files and I using same version of XAMPP & PHP on that both computers
Localhost targets on your computer, means the actual machine the files are on. If you are using php > 5.3 you can use php's build in development server with
php -S __YOUR LOCAL IP__ : 8000
and access the site from all the computers within your network
For example, if you run
php -S 192.168.0.1:8000
on your development machine, you can access it via
http://192.168.0.1:8000/
from every device connected to your local network
As you have written in your comment you have copied all the files, it is most likely that you either don't have php, apache or a webserver (MAMP,WAMP,...) installed (or started) on the other machine, or you just didn't copy the files to the correct folder.
an url beginning with localhost refers to the computer where it's called from. See wikipedia localhost.
To provide the same behavior on another computer you need to copy the whole project and install the used server software e.g. apache, mysql etc. pp. or access the project from another computer in the same network using the internal network IP instead of localhost.
FYI: localhost is almost the same like the loop-IP 127.0.0.127
so on the computer where it works there should also work: http://127.0.0.127:8080/task_manager/v1/register
Now replace the 127.0.0.127 with the IP of your computer when testing it on another computer
You need to run your project on a webserver like your local.

php hello world in eclipse not working

I have created a simple hello world php app in eclipse with the name od FirstPHP
when i try to run it as "run as php web page"
it tries opening the page
http://localhost/FirstPhp/first.php
in eclipse web browser
and got the message web page not found
when i open http://localhost:8080/ it works fine , so tomcat is ok
Any Suggestion
AFAIK, Eclipse doesn't automagically configure your webserver so that its document root is suddenly wherever sits the project that you just so happen to currently be working on.
Configure your webserver to use the proper path as DocumentRoot.
I also notice that you used the wrong port number in the first instance.
Install your server correct. Why do you use Tomcat in the first place. Thats not primarily used for PHP, but for JSP.
Check if localhost:80 works fine too, thats where he wants to go...
Make sure you set the DocumentRoot in Eclipse.
Gr.

Categories