I'm trying upgrade my laravel project from 5.2 to 5.3.
Since laravel 5.3, the route files are kept in a separate directory routes, instead of the previous app\Http directory. I created the file routes/web.app and pasted my routes into this file.
When i execute php artisan route:list, it returns:
+--------+----------+-------------------+------+--------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-------------------+------+--------------------------------------------+------------+
| | GET|HEAD | captcha/{config?} | | \Mews\Captcha\CaptchaController#getCaptcha | web |
+--------+----------+-------------------+------+--------------------------------------------+------------+
My routes/web.php file:
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function(){
echo 'here';
});
Where is my route?
When I access the home page, it returns a 404 error, but the error comes from laravel.
The file .htaccess is ok.
You said:
I created the file routes/web.app and past my routes on file.
In Laravel 5.3 the web.php file is already created in the routes directory. If you have recreated this file that is where the problem may be propagating from.
I read the upgrade documentation and thought I needed to remove the EventServiceProvider, RouteServiceProvider, AuthServiceProvider methods from the boot ....
But in fact I needed to update the contents of these files.
After updating the contents to the new version 5.3 up to where I tested, it is working ....
Related
im trying to install Laravel in my shared hosting website's(which is not laravel) subfolder.
for example in: example.com/dev
Structure:
->laravel
->app
->bootstrap
->public_html
...example.com folders & files
->dev
->css
->js
->.htacess
->index.php
... other Laravel public files
My example.com/dev/index.php looks like this:
... laravel codes
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../../laravel/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
... laravel codes
Problem:
When i try to enter http://example.com/dev/ browser throws error:
This page isn’t working
mysite.com didn’t send any data.
ERR_EMPTY_RESPONSE
THERE ARE NO ANY INFORMATION/SOLUTION FOR THIS PROBLEM IN THE INTERNET.
ANY SOLUTION?
Your entire project should be inside your public_html folder. Then move all the contents of your public folder to public_html as well. Then edit your index.php to match the proper directory for autoload.php and app.php
From your text I assume you want call Laravel via http://example.com/dev/ If you hoster allows symlinks, you can try this.
-> laravel
-> app
-> ...
-> public // symlinked to public_html/example.com/dev
-> ...
-> public_html
-> example.com folders & files
-> dev // This is a symlink to laravel/public
A better approach in my opinion would be to create a subdomain and call Laravel like http://dev.example.com. It depends on your hoster how you can do this.
i'm trying to build a hyperlink from index.blade.php to login.blade.php by route. i defined a named route for this hyperlink but is not working.
here is my route code.
Route::get('/','HomeController#index');
Route::get('/login', 'HomeController#login_page')->name('login');
and here is my controller.
public function login_page()
{
return view('login');
}
and here is my view where i'm trying to set a hyperlink.
<li>Log-in</li>
Set URL link in a menu link using Laravel blade template, use it {{url('dashboard')}}. Use this link in the for example:
<ul>
<li>
Dashboard
</li>
</ul>
I think it will be helpful for you.
Your error message points to a server problem, not Laravel.
Make sure you'r mod_rewrite for apache is installed and enabled.
a2enmod rewrite
service apache2 restart
Then check your Laravel with:
In your console, run: php artisan route:list and see if you have a row similar to:
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------+---------------+---------------------------------------------------+-----------------------------+
| | GET|HEAD | login | login | App\Http\Controllers\HomeController#login_page | web,guest |
If you do not see the login part, try clearing route's cache with:
php artisan route:clear
Other than that, you are doing everything properly.
I had the same problem (Ubuntu 18.04), it does not seem to be Laravel but Apache.
Workaround: Install Xampp and use it as Localhost.
directory structure
laravel package
| |-project1
| |-app
| |-config
| |-resources
| |-project2
| |-app
| |-config
| |-resources
|-env
| and other files
|
i need the folder structure to be like above mentioned.please mention as tutorial as i am new to laravel. as i like to run multiple projects in the same laravel package without installing a new package sharing other files like env ,vendor etc.,
You could do something like this:
You can namespace all files under the app folder and prefix everything with 'project1', 'project2', etc
App/Project1/Models/etc...
App/Project1/Controllers/etc...
App/Project2/Models/etc...
App/Project2/Controllers/etc...
And in your route files, connect the routes to the different namespaces:
Route::group(['namespace' => 'App\Project1\Controllers'], function()
{
Route::get('/', 'HomeController#index');
});
You can even make different route files for different projects and load them through the RouteServiceProvider#map method...
But to be honest, I would never go this way. Laravel is so easy to load through composer, what is the problem? The whole system runs so smoothly, why try to introduce these dimensions? But if you really want to, there is always a way... :-)
I am building a frontend symfony app for a project with the current folder structure:
+---app
| +---conf
| +---lib
| | +---ca
| | | +---Search
+---frontend
| +---app
| +---bin
| +---src
| | \---PublicBundle
| | +---Controller
The app folder on root is where another (non symfony app) is located. It is a php app.
Inside the frontend folder is where symfony project is being built.
I am trying to load from inside the symfony app (from the public controller) a class from the other php app (a class inside the ca subfolder) but when I try to, symfony returns a namespace exception with the tip: Did you forget a "use" statement for another namespace?
It is correct to load a class from outside a symfony project like is, and if it is how is it done?
Thanks in advance,
i've been stumped by thhis one for a couple of days now. I get this error when i try loading the main page, I get the error in the title. I've asked this question here and tried putting dd() at the top of the page as well as running php artisan route:clear as well as other commands hoping I can get the home page to load. The funny thing is I can load the user login function no problem.
Here's my routes file:
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('pages.home');
});
Route::auth();
View Structure:
I found my problem. I didnt notice this before, but my project in PhpStorm was being saved to a directory outside my VM. i apologize for not figuring this out earlier.