bynder / gathercontent-laravel-fractal Goto Github PK
View Code? Open in Web Editor NEWA Fractal Service Provider for Laravel
A Fractal Service Provider for Laravel
Cannot set a custom serializer at runtime.
Typically, this won't be needed - however I've been thinking about a different Serializer for Error Transformers:
{"error":{"message":"Access Denied"}}
This would require a custom serilizer appending data to an 'error' key, similar to the DataArraySerilizer bundled with Fractal itself.
Can possibly just add it onto the service class:
Fractal::setSerializer(new \Acme\ErrorArraySerializer);
I'm not sure if I am doing something terrible wrong or not. But are includes working? I notice the config has a place to change the includes word but I can't seem to get it to include my requests without explicitly adding $defaultIncludes.
After following install instructions for this package on Laravel 5 (added alias and Service provider registrations
php artisan config:publish gathercontent/laravel-fractal gives
[BadMethodCallException]
Call to undefined method [package]
Any attempt to run the package gives the following error:
BadMethodCallException in ServiceProvider.php line 226:
Call to undefined method [package]
in ServiceProvider.php line 226
at ServiceProvider->__call('package', array('gathercontent/laravel-fractal', 'fractal')) in LaravelFractalServiceProvider.php line 22
at LaravelFractalServiceProvider->package('gathercontent/laravel-fractal', 'fractal') in LaravelFractalServiceProvider.php line 22
at LaravelFractalServiceProvider->boot()
at call_user_func_array(array(object(LaravelFractalServiceProvider), 'boot'), array()) in Container.php line 526
at Container->call(array(object(LaravelFractalServiceProvider), 'boot')) in Application.php line 703
at Application->bootProvider(object(LaravelFractalServiceProvider)) in Application.php line 685
at Application->Illuminate\Foundation{closure}(object(LaravelFractalServiceProvider), '19')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(ControllerServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FormRequestServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ValidationServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(BusServiceProvider), object(ConfigServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(LaravelFractalServiceProvider), object(BusServiceProvider)), object(Closure)) in Application.php line 686
at Application->boot() in BootProviders.php line 15
at BootProviders->bootstrap(object(Application)) in Application.php line 183
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 199
at Kernel->bootstrap() in Kernel.php line 110
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
In LaravelFractalService
the collection
and paginateCollection
methods are type-hinting IlluminatePaginator
. I want to use my own adapter that implements League\Fractal\Pagination\PaginatorInterface
but does not extend IlluminatePaginator
. As along as my adapter implements the interface it will work. Also, it is usually recommended to type-hint interfaces when possible.
When I try to use my own adapter I get an error due to the type-hint expecting an object that is an IlluminatePaginator
object.
fractal 0.9.* is available
I create ussue on larasponse lib, i think that that's your bug:
salebab/larasponse#10
Is laravel 5 supported?
For convenience, Item
and Collection
are created within the LaravelFractalService
class, which acts as a Facade
, hiding complexity. This is nice within our controllers since it allows:
return Fractal::item($user, new UserTransformer);
Problem is, meta is added at the resource level, which we do not have any access to.
One possible solution could be to pass a closure as a third param:
return Fractal::item($user, new UserTransformer, function ($resource) {
$resource->setMetaValue('foo', 'bar');
});
This class would be more open for extension if I could get the manager.
Fractal::getManager();
Because this is not provided, I've logged #1 which could have been avoided if I could access the manager.
The pagination is never executerd due to comeration to "IlluminatePaginator" Laravel 5 users LengthAwarePaginator so if statement is never executed. Fix would be appreciated :)
Instead of having to pass a transformer, a strategy could be defined to automatically resolve the Transformer. This strategy could be set or injected into the manager. Any sort of resolver really.
Perhaps an EloquentTranslator
could also translate the model class into a translator similar to how a Command
finds it's own CommandHandler
. For example:
\Acme\Users\User
finds \Acme\Users\UserTransformer
This must be highly configurable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.