I downloaded Laravel 5.4.28 and created one api route. Nothing works on localhost. I am using XAMPP on Windows 8.1 as local development.
But everything is working fine on server. I also notice one strange thing. It will work on localhost if I create virtual host on localhost. like below.
php artisan serve
Is that true? or Am I missing anything?
My api routes are like this...
http://localhost:1234/adminapi/public/api/v1/authenticateuser
If your XAMPP works normally with normal PHP pages, did you check which version of php XAMPP uses ? the minimum required version is
PHP >= 5.6.4
Laravel Official Website
The default version of XAMPP's PHP framework is 5.6.30
I have faced the same problem, it turned out that I had only problem with PHP version I just upgraded the version of php.ini from 5.6.3 to 7.0.1 new versions of XAMPP have them both !
First of all you need to create virtual host for your project like yourprojectname.local. and test your app through this url.If you not create virtualhost then you need to give whole path for access laravel api like localhost/yourprojectdirectory/public/adminapi/public/api/v1/authenticateuser
You can bellow link refer to the creating virtual host
http://foundationphp.com/tutorials/apache_vhosts.php
OR
How To Set Up Apache Virtual Hosts on XAMPP (Windows)
When you do php artisan serve and load the URL returned by that command do you see laravels welcome page? If not then you haven't installed it correctly. https://laravel.com/docs/5.4
The php artisan serve command doesn't create a virtual host, it 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.
There's a property in config/app.php called url.
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
By default it links to .env file's property called APP_URL. XAMP usually requires you to navigate to localhost/project_folder before you can even access your project, hence why you need to set your url property to the one you're using.
Second, API routes usually are prefixed with /api/ and do require a X-REQUESTED-WITH: XMLHttpRequest header.
If you install fresh laravel app, you base api prefix must be equal api.
you route in api.php
Route::get('test', 'TestController#test');
If now you run php artisan serve command, api will be available to
localhost:8000/api/test.
Hope, I help you.
I was facing the same with Apache on Windows. Following the next steps below, it worked for me.
First, look for your file httpd.conf into Apache.
Find the section...
<Directory /var/www/>
Change
AllowOverride None
to
AllowOverride All
Finally, restart the Apache service.
Related
I just migrated from a windows based laptop to a macbook.
I'm pretty new to MacOS
I'm developing a laravel project in my mac and I want to access the url through custom domain using virtual host such as mylaravel.com or something else, i'm not using xampp, only php, and composer.
for example:
currently I access my laravel project through:
sudo php artisan serve --port=80
and this is the url to access my
localhost
what I want is the following url:
mylaravel.id
How can I achieve it?
Thank you.
you can use laravel valet.
look at this documentation.
i have a pc and desktop, they both used to have xampp and laravel 5.7, recently i updated laravel to 5.8 in my desktop and reset laptop and install laravel 5.8,, routes are working all fine in desktop laravel version ,, but in newly installed laravel in laptop they aren't working, i get 404 error except '/' i tried override all, ifmodule solution they are all fine it is not working in newly installed laravel 5.8 please help ...
PS : i also created seprate project in desktop and laptop ,, not copy paste but individually created in both of them..
i checked apache hhtp.config for ifmodule and overrride and htaccess is default i haven't modified any and is same as all them in solution
i want to be able to use routes without using php artisan serve
Check the configuration of the Directory section in the vhost settings of xampp.
I have a laravel project and I can access this application through virtual server (tracking.com) locally. When I run through virtual server all the routes are working perfectly. But when I access the application through localhost (localhost/tracking/public) routes are not working except home page.
Home Route
Route::get('/', 'DashboardController#info')->middleware('auth');
Non-working routes
Route::resource('depot', 'DepotsController')->middleware('auth')
All routes are working well with virtual server. With virtual server both routes are working home page(tracking.com) and depots page (tracking.com/depot).
but with localhost only (localhost/tracking/public) is working and (localhost/depot) is not working.
There are three solutions to this issue -
1) If you have Apache or Nginx installed, configure your vhost to point to /public/ directly
2) Use Laravel Homestead
3) Navigate to your project-folder/ within your terminal and run php artisan serve, you can now browse to http://localhost:8000 directly in your browser
Ref: If you are going with the first approach - Click here
use php artisan serve and navigate to 127.0.0.1:8000 from they all the routes will work
Fairly new to Laravel here and I'm struggling to understand how to make Laravel 5.2 aware of where it resides. Here's the issue:
I set up auth using php artisan make:auth, and can now see the lovely landing page, as well as login and register links in the menu. The problem is that these links don't go to the right place. They point to /login and /register in the code respectively, which translates into http://localhost/login or http://localhost/register. But since I'm not on a production site yet and am developing locally, my website resides at http://localhost/projectname/public.
I've gone into config/app.php and tried various values for the URL parameter, but these have no effect.
What can I do to get these links to reflect the full site URL, without manually entering it each time?
you can run the development server in laravel using this command
php artisan serve
Did you try that?
Use laravel url function:
{{ url().'/login' }}
/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 411
This error above I've faced on a free hosting service that uses PHP 5.3
I'm trying also on another paid service with PHP 5.3 and I'm getting the 500 Internal Server Error, and I made sure my routes and paths are good to go. (The index.php in the public folder, and the /bootstrap/path.php files are good to go with DIR URIs).
Now I'm sure I will keep getting these kind of errors and my app won't work unless I host it on a service with PHP 5.6, but I was hoping there would be a way that I could downgrade my Laravel version or PHP version for some kind of Backward Compatibility.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, cgiadmin#yourhostingaccount.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
My files are in the root directory, and there isn't any folder named public_html and so the files originally in the Laravel/public folder are dispersed in the root directory and my other application files and folders are in a folder in the root directory.
Any suggestions or help would really be much appreciated.
Laravel 4.2 requires PHP 5.4.
Laravel 4.2 requires PHP 5.4 or greater. This upgraded PHP requirement
allows us to use new PHP features such as traits to provide more
expressive interfaces for tools like Laravel Cashier. PHP 5.4 also
brings significant speed and performance improvements over PHP 5.3.
Please see this for more information: http://laravel.com/docs/4.2/releases
Your question is quite unclear, because you first state that you get the 500 Internal Server Error when using PHP 5.6 (in the title and, assumedly, the tag), but then you say that "[the] app won't work unless [you] host it on a service with PHP 5.6".
I have come over this problem with editing the .htaccess file within the /public_html folder of the server.
OR
By using the cPanel's Redirects and make it Redirect the server to the
domain.com/{if it's inside a folder inside the public_html}/index.php
and then ALL Routes and links worked perfectly fine.
If you want to change the URL and use Pretty URLs refer to the Laravel Documentations under Configuration.