Namespace declaration statement has to be the very first statement in the script

Namespace declaration statement has to be the very first statement in the script

I just started to develop web application with Laravel, I have a problem to use the dependency injection. It works fine without the DI, but I want to refactor the code so that the code is not tightly coupled.

I already search in google that suggests perhaps there is a white space before the namespace and search related questions here, but none of them solve my problem.

AccountController

<?php

namespace TabJutHttpControllers;

use IlluminateHttpRequest;
use IlluminateSupportFacadesInput;
use IlluminateSupportFacadesRedirect;
use IlluminateSupportFacadesValidator;

use View;

use TabJutHttpRequests;
use TabJutHttpControllersController;
use TabJutRepositoriesAccountRepository;

class AccountController extends Controller
{
    /* error culprit, If I remove these the page not error */
    protected $repository;

    public function __construct(AccountRepository $repository)
    {
        $this->repository = $repository;
    }
    /* error culprit */

    public function getLogin()
    {
        return View::make('account.login');
    }

    public function postLogin()
    {
        // Validates inputs.
        $rules = array(
            'username' => 'required', 
            'password' => 'required'
        );
        $validator = Validator::make(Input::all(), $rules);

        // Redirects back to the form if the validator fails.
        if ($validator->fails()) {
            return Redirect::action('[email protected]')
                ->withErrors($validator)
                ->withInput(Input::except('password'));
        } 

        $username = Input::get('username');
        $password = Input::get('password');
        $user = $repository.Authenticate($username, $password);
        var_dump($user);
    }
}

AccountRepository

<?php

namespace TabJutRepositories;

use DB;

class AccountRepository
{
    public function Authenticate($username, $password)
    {
        $user = DB::table('users')
                    ->where('is_active', '1')
                    ->where('user_name', $username)
                    ->where('password', $password)
                    ->first();    
        return $user;
    }
}

Folder Tree

Folder Tree

Error Message

FatalErrorException in AccountRepository.php line 3: Namespace
declaration statement has to be the very first statement in the script

in AccountRepository.php line 3
at FatalErrorException->__construct() in HandleExceptions.php line 127
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 112
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at ComposerAutoloadincludeFile() in ClassLoader.php line 301

Did I miss any important configuration like service locator setup or just unseen code error?

Please help.

It has nothing to do with the dependency injection, based on kuzawinski comment on the manual, I recreated the file with notepad and it solves the problem.

…and you still get “Namespace declaration statement has to be the
very first statement in the script” Fatal error, then you probably use
UTF-8 encoding (which is good) with Byte Order Mark, aka BOM (which is
bad). Try to convert your files to “UTF-8 without BOM”, and it should
be ok. Comment

.
.
.
.