Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

[L5] Input, HTML, Form facades etc

Just tried installing L5 with great pleasure but then moved some code over from L4.2 to :5 but I need to use the Input::, {{ Form::open() }} stuff

I pulled in illuminate/html: ~5.0" as I saw in a previous post but then the app breaks.

So more videos from @JeffreyWay on these type of subjects would be great, in that case I'm going to stick to 4.2 for now on a new project until I can get time ti toy with L5.

0 likes
28 replies
theUnforgiven's avatar

I can login but then I get:

FatalErrorException in LoginController.php line 12: Class 'Trax\Http\Controllers\Input' not found

    in LoginController.php line 12
    at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Class 'Trax\Http\Controllers\Input' not found', 'file' => '/home/vagrant/code/trax/app/Http/Controllers/LoginController.php', 'line' => '12')) in HandleExceptions.php line 116
    at HandleExceptions->handleShutdown()
RachidLaasri's avatar

Add this to the composer.json file and run composer update.

"illuminate/html": "4.3.*

register the ServiceProvider

'Illuminate\Html\HtmlServiceProvider'

add the facades

'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade'

and it should work just fine.

Also @MThomas i believe TO changed the escape method.

1 like
theUnforgiven's avatar

Yep that seems to have worked! I'm now logged in so I guess I just have to use "old" stuff

RachidLaasri's avatar

Whenever you use "Redirect, Input, Validator", you need to import it.

theUnforgiven's avatar

@bashy it is namespaced, but not having the "use" statements doesn't work

<?php namespace Trax\Http\Controllers;

use Input;
use Auth;
use Redirect;

class LoginController extends Controller {

    public function login()
    {
        return view('login');
    }

    public function authenticate()
    {
        $username = Input::get('username');
        $password = Input::get('password');

        if (Auth::attempt(array('username' => $username, 'password' => $password, 'status' => 'Active'), false)) {
            return Redirect::intended('dashboard')->with('flash_success', 'You are now logged in.');
        }
        else {
            return Redirect::to('/')
                ->with('flash_error', 'The details you entered where incorrect.<br />Please check and try again')
                ->withInput();
        }
    }

    public function dashboard()
    {
        return view('dashboard');
    }

}
1 like
RachidLaasri's avatar

You must import them, also you can replace that line with

use Input, Auth, Redirect;
theUnforgiven's avatar

So namespacing doesn't import, or is there a better way to do this, still new to L5 and not really played with it until now and really want to use it on this new project I have got, specially for method injection.

theUnforgiven's avatar

Also I copied the .env.example file and named it .env.local.php with the following inside it

APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString

DB_HOST=localhost
DB_DATABASE=erp
DB_USERNAME=homestead
DB_PASSWORD=secret

And this didn't get picked up and was still showing as production when I did php artisan env

RachidLaasri's avatar

@lstables First question, i believe there's no other way to do it, this is how namespacing works.

Second question, rename your file to .env.local without .php extension.

theUnforgiven's avatar

I don't mind/have no issue doing "use" if that's how its to be so that's fine. Has for .env files will that be .env.local and .env.production respectively?

theUnforgiven's avatar

Reason I ask i have no changed to .env.local and when I php artisan env it still states "production"

theUnforgiven's avatar
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString

DB_HOST=localhost
DB_DATABASE=erp
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file

But if I echo out like so {{ getenv('APP_ENV') }} it does show local, but doing php artisan shows production!

RachidLaasri's avatar

I literally have no clue, it's working fine for me, I am sorry.

opb's avatar

It's just .env, wherever you put it. Use APP_ENV=local within the .env file to specify the environment.

1 like
theUnforgiven's avatar

Next question would be what about Form model binding? for editing a page with values filled with stuff from the db?

RachidLaasri's avatar

what about it? The idea of Form model binding is that you can pass the data to a form and it'll automatically get filled with the data that matches the inputs names.

theUnforgiven's avatar

yes how does this work in L5 ? in L4 we did things like

{{ Form::model($user, ['method' => 'PUT', 'route' => ['product.update', $user->id], 'class' => 'form-horizontal']) }}

Reason I ask all these questions is @JeffreyWay hasn't updated new videos with this stuff on and Taylor is updating this docs this week as far as I know.

theUnforgiven's avatar

Ah right that's cool then, I know Jeff is working on these I meant to say he's not at this point yet.

RachidLaasri's avatar

Yeah, he already started putting L5 screencasts, but he stopped until L5 is ready, now that it'll go beta in a week or two

he decided to continue teaching L5.

1 like
bashy's avatar

I didn't mean namespacing "does" it for you, meant if you namespace classes, you have to start importing things to be able to use them :)

Please or to participate in this conversation.