jarektkaczyk / eloquence

Extensions for the Eloquent ORM
http://softonsofa.com
MIT License
1.09k stars 142 forks source link

Using eloquence outside laravel #18

Closed icubed-web closed 9 years ago

icubed-web commented 9 years ago

Hi , would it be possible to use outside of laravel ? Im using slim with eloquent .

Thanking your in advance .

jarektkaczyk commented 9 years ago

Yes it should work. It depends on illuminate/database and illuminate/contracts.

The only thing that you need to do for sure, is setting up the factories, just like in the service provider:

    public function boot()
    {
        Builder::setJoinerFactory(new JoinerFactory);

        Builder::setParserFactory(new ParserFactory);
    }
icubed-web commented 9 years ago

Thank you ,

I really appreciate your response .

icubed-web commented 9 years ago

Hi ,

Im having some issues using eloquence , im getting this error :

Call to a member function make() on null

I know you said that I should set up factories , so how would you exactly do that ?

Thanking you in advance .

jarektkaczyk commented 9 years ago

@icubed-web You should do that before using Eloquent. The best will be when your app is bootstrapping - that's what Laravel's ServiceProviders do. Now, I don't know about slim, but there must be some kind of similar process, so this will be it.

icubed-web commented 9 years ago

Hi jarek ,

Thank you for your help ,

I did manage to boot eloquence like so ...


use Sofa\Eloquence\ServiceProvider as Eloquence;

$test = new Eloquence;

$test->boot();

but I am getting an issue ?

Missing argument 1 for Illuminate\Support\ServiceProvider::__construct(),

Dont know what I should be calling ....

And thank you for your time , thank you for helping me out .

I really do appreciate it .

icubed-web commented 9 years ago

Hi jarek ,

I would really love to thank you for all your help and for this great repository ,

I have finally got it to work and it was as simple pie ...

here is my code and thank you again .


use Illuminate\Support\ServiceProvider as Provider;

use Sofa\Eloquence\ServiceProvider as Eloquence;

$test = new Eloquence('Sofa\Eloquence\ServiceProvider');
$test->boot();

Best Regards