Support the ongoing development of Laravel.io →
posted 10 years ago
IOC

Hello,

I've just create my own Facade and I'd like to handle sessions in my method, But when I try to use something like this:

if ( Session::has('login') ) 
{
    // do something
}

Laravel returns a FatalException with this message: Class 'Myfacades\Services\Session' not found The same if I use any Laravel Class (Input, ecc).

Why? Thanks in advance

Last updated 3 years ago.
0

That's just namespacing basics. Since your facade is in the MyFacades\Services namespace, just trying to call Session looks for it in the same namespace. You'll need a use statement at the top of your file.

http://www.php.net/manual/en/language.namespaces.php

Last updated 3 years ago.
0

Thanks for your reply. But How to use?

I have

namespace Yvoting\Services;
class HelloWorld  
{
        public function sayHello()
        {
            $vv = Session::get('sss', 'sssf');
    }
}
Last updated 3 years ago.
0

Solved, thanks thepsion5:

namespace Yvoting\Services;
use Session;

class HelloWorld  
{
    public function sayHello()
    {
        $vv = Session::get('sss', 'sssf');
    }
}
Last updated 3 years ago.
0

Or you can do this also:

\Session::get('bla');

Last updated 3 years ago.
0

Oh, yes. Sure. Thanks psychonetic

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.