Laravel routes are not found in 000webhost - php

I'm building a simple blog for my personal projects with Laravel 5.4.36. I have uploaded it to 000webhost. The problem is everytime I`m trying to sign up or sign in, it is saying,
The requested URL was not found on this server
Here is the URL that is shown during this error,
https://myprojectblog.000webhostapp.com/signUp
Here 'signUp' or 'signIn' are provided in the routes file which are given below,
Route::post('/signUp', [
'uses'=>'UserController#postSignUp',
'as'=>'signUp'
]);
Route::post('/signIn', [
'uses'=>'UserController#postSignIn',
'as'=>'signIn'
]);
The sign up form is given below,
<div class="signUp">
<label>Sign Up</label></br>
<form action="{{ route('signUp') }}" method="POST" name="signUp" id="signUp">
<label id="usernameLabelSignUp">Username</label></br>
<input type="text" id="usernameSignUp" name="username" value="{{ Request::old('username')}}"></br>
<label id="emailLabelSignUp">Email</label></br>
<input type="text" id="emailSignUp" name="email" value="{{ Request::old('email')}}"></br>
<label id="passwordLabelSignUp">Password</label></br>
<input type="password" id="passwordSignUp" name="password"></br>
<input type="hidden" name="_token" value="{{ Session::token() }}">
<input type="submit" id="signUpSubmit" value="signUp">
</form></br>
</div>
In the cpanel of 000webhost my file structure is,
/
-Blog
-All the Laravel project directories and files except public
-public_html
-public
-css
-js
-.htacess
-index.php
-favicon.ico
-robots.txt
-web.config
My index.php in /public_html/public got included these lines,
require __DIR__.'/../Blog/bootstrap/autoload.php';
$app = require_once __DIR__.'/../Blog/bootstrap/app.php';
The index page loads without any trouble, but while trying to sign in or up the error occurs.
Most importantly everything runs absolutely fine in my local machine, no trouble at all.
Some clue would mean great help. Thank you.

Related

Route [customer.password.request] not defined

I am trying to get my development box to work so I can work on a development at home as not to alter and mess up the main site.
I get an error on the development box but not on the main site.
I have set everything up then copied the site via another tutorial. I was able to get all the requirements working and the site works except when I attempt to go to the log in page. I have searched the web for the method used for the route and I cannot find a good explanation of how it works so I can troubleshoot the problem.
div class="col-lg-6 col-md-8 col-sm-8 col-lg-offset-3 col-md-offset-1 col-sm-offset-2">
#if(Session::has('errors'))
<div class="alert alert-danger text-center">
#php ($errors = Session::get('errors'))
#php ($err = $errors->toArray())
{{$err['email'][0]}}
</div>
#endif
<form role="form" id="cust-login-frm" method="POST" action="{{ route('xxx') }}" >
{{csrf_field()}}
<input name="user_type" type="hidden" value="{{ Crypt::encrypt('XX') }}">
<div class="form-group">
<label>Email</label>
<input type="email" id="email" name="email" class="form-control" placeholder="Email" value="{{(Session::has('failed')) ? Session::get('failed') : ''}}">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Password">
</div>
<div class="clearfix"></div>
</form>
<div class="form-group col-lg-12 submitbtn">
<!-- <input type="hidden" name="save" value="contact"> -->
<button id="cust-login-btn" class="btn btn-primary" type="button">Sign In</button>
</div>
<center><div> Not Registrated? Register | Forgot Password? </div></center>
The issue I am having is the hyperlink towards the bottom "{{route('customer.password.request') }}" The route before it I can find and follow but this one with the dot notation I cannot. I cannot provide too many details as this is a live site. I suspect this broke due to my command composer update. The main site was not coded by me and has tons of issues. But it will work and its the same. This one is difficult as the main laravel.org does not have much on the subject. If a guru here can point me to a tutorial or page that will help me understand why I am getting the error "Route [customer.password.request] not defined. (View: /var/www/html/resources/views/customer/auth/xxx.blade.php)". Thanks community. :)
NOTE: I have removed some parts to hide real filenames with xxx.
Define the route name in web.php
Route::any('urlname','controllername#functionname')->name('customer.password.request');
Ok the answer to my question here is this.
I found out that the routes were placed in the wrong location.
The morons who did this put the routes in the vender folder file. This was changed when I did an update. So I decided to move them to the web.php and it worked.
So this issue can be closed.
Thanks.

how to solve Laravel routes conflict

this is a simple code to search in laravel.
the route "product" has no problem at all, but,
when I use the route "searchproduct", the url in the browser looks like this:
http://example.com/application/public/product/search?q=red+dead
so the application thinks that i'm trying to get the route "product" and send the parameter urlkey as "search?q=red+dead", which ofcourse throw an error.
View
<form method="GET" action="{{ route('searchproduct') }}" >
<input id="q" name="q" class="q" type="text" />
<button type="submit" id="submitButton" class="btn btn-primary">Go</button>
</form>
Routes
Route::get('product/{urlkey}','ProductController#index')->name('product');
Route::get('product/search/{q?}','ProductController#search')->name('searchproduct');
how to solve this issue please?
define routes this order
Route::get('product/search/{q?}','ProductController#search')->name('searchproduct');
Route::get('product/{urlkey}','ProductController#index')->name('product');

Unable to load the "Symfony\Bridge\Twig\Form\TwigRenderer" runtime

I've been working through various hurtles toward migrating an existing Symfony3 web app from a local LAMP host up to Goggle's App Engine Standard PHP Environment. I've taken hints from the appengine-symfony-starter-project to use Memcache for sessions, pre-cache the application code, and connect to a Cloud SQL MySQL database. In have the core pieces working fine.
I added a login form at /login using a TWIG template with a form in it that goes like so:
<form class="form" action="{{ path('security_login') }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" />
<div class="form-group">
<input class="form-control" id="email" type="text" name="_email" placeholder="Email" value="{{ last_username }}"/>
</div>
<div class="form-group">
<input class="form-control" id="password" type="password" name="_password" placeholder="Password"/>
</div>
<div class="form-group">
<input type="checkbox" id="remember_me" name="_remember_me" checked>
<label for "remember_me">Remember Me</label>
</div>
<div class="form-group">
<button class="btn btn-round btn-b">Login</button>
</div>
<div class="form-group">Forgot Password?</div>
</form>
This works fine in the local DEV and TEST environments but when I push this up to GAE, I'm getting the error below:
Unable to load the "Symfony\Bridge\Twig\Form\TwigRenderer" runtime.
I've been digging for a couple hours now and haven't found a hit as to what's wrong here. Anyone have any ideas where to look?
Thanks in advance,
In my case "twig.strict_variables: true" to "twig.strict_variables: false" fixed an issue.
We encountered the same error this morning at work, in a Silex app.
This helped us: https://github.com/silexphp/Silex/pull/1571
It worked for us to change in our composer.json the version of symfony/form from ~2.8|^3.0 to ~2.8|3.3 as it appears TwigRenderer is deprecated in 3.4.
Hope this helps.

getting laravel local host path error (object not found)

I'm new to laravel and still learning about this framework.
I already found some questions on stackoverflow but it still didn't work out for me.
My problem is:
I got this
localhost/codehub/public/users/create
and the route:
Route::get('users/create',['uses' => 'UserController#create']);
Inside the page there's some form like this:
so when I click create button it is supposed to route it into store function in the user controller
Route::post('users',['uses' => 'UserController#store']);
public function store(Request $request)
{
return $request->all();
}
so the problem is when I click that create button it always redirects me to localhost/users and because of that, I can't process my store function.
Any advice?
this is my form code:
<form method="post" action="/users">
<input type="text" name="name">
<input type="email" name="email">
<input type="password" name="password">
<input type="submit" value="Create">
</form>
The problem may be because of relative path in form action.
You should always use named routes which allow the convenient way of generation of URLs or redirects for specific routes.
So you can change your route as:
Route::post('users', 'UserController#store')->name('users.create');
And in form you can write as:
<form method="post" action="{{ route('users.create') }}">

Laravel "Token mismatch" every first attempt

First: I know that this have been asked before, but that is quite awhile ago and no one had a solving answer. In this period of time, i hope someone else has figured.
Whenever i sign out of my laravel application (whether that be manually or by timeout) and i try to sign in, i get this error:
TokenMismatchException in VerifyCsrfToken.php line 67:
This is the form:
<div class="login_wrapper">
<form method="POST" action="/auth/login">
{!! csrf_field() !!}
<input type="text" name="email" placeholder="{{ trans('nosession.login_email') }}">
<input type="text" name="password" placeholder="{{ trans('nosession.login_password') }}">
<input type="checkbox" name="remember"> Remember Me
<input type="submit" class="btn okay" value="{{ trans('nosession.login_button') }}">
</form>
</div>
I'm using the default Auth feature in Laravel, only changed the table. Sign-in works on second attempt without any problems. Any ideas?
Ps. I've tried changing {!! csrf_field() !!} to { csrf_field() }, as some people suggested it.
UPDATE:
Apparently it seems like Middleware, causing the trouble. Is it necessary to use that?

Categories