apiato / core Goto Github PK
View Code? Open in Web Editor NEWApiato Core Package
Home Page: http://apiato.io/
License: MIT License
Apiato Core Package
Home Page: http://apiato.io/
License: MIT License
Laravel's middleware prioritization should work with Apiato after adding middlewares to $middlewarePriority.
After adding middlewares to $middlewarePriority in any MiddlewareServiceProvider those middlewares are not registered in the router.
I found this issue because I needed a container's middleware to be executed after the Authenticate middleware. Due to the Authenticate middleware is registered in the router instance after all the containers' middlewares are registered, the containers' middlewares are always executed before the Authenticate middleware. in fact, the containers' middlewares are executed before the throttle.
When running tests (php artisan test) on apiato 11, most tests fail.
Most tests fail because of incorrect namespace fabric classes:
Class "App\Containers\AppSection\User\Data\Factories\Containers\AppSection\User\Models\UserFactory" not found
When calling a static method ::fabric in model - The correct namespace is formed "App\Containers\AppSection\User\Data\Factories\UserFactory"
I found the problem in a trait FactoryLocatorTrait:
function !class_exists($nameSpace . $className . 'Factory', false)
return true, Although it should return false
Class "App\Containers\AppSection\User\Data\Factories\Containers\AppSection\User\Models\UserFactory" not found
After making a composer update
this error appeared. I deleted the vendor folder and rerun composer install
again but without any results.
When try to generate a web crud crontroller from cli command php artisan apiato:generate:controller
and exception is returned after setting the follow options:
laradock@7ea54c192cf0:/var/www/apiato$ php artisan apiato:generate:controller
Enter the name of the Section [AppSection]:
>
Enter the name of the Container:
> Authorization
Enter the name of the Controller file [Controller]:
> RolesController
> Generating (RolesController) in (AppSection:Authorization) Container.
Select the UI for the controller [API]:
[0] API
[1] WEB
> 1
Select the Stub you want to load [Generic]:
[0] Generic
[1] CRUD.API
[2] CRUD.WEB
> 2
File does not exist at path /var/www/apiato/vendor/apiato/core/Generator/Stubs/controllers/web/crud.web.stub.
Illuminate\Contracts\Filesystem\FileNotFoundException
File does not exist at path /var/www/geus-2/vendor/apiato/core/Generator/Stubs/controllers/web/crud.web.stub.
at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:59
55▕ if ($this->isFile($path)) {
56▕ return $lock ? $this->sharedGet($path) : file_get_contents($path);
57▕ }
58▕
➜ 59▕ throw new FileNotFoundException("File does not exist at path {$path}.");
60▕ }
61▕
62▕ /**
63▕ * Get contents of a file with shared access.
+15 vendor frames
16 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
Checking the refered path the stub file crud.web.stub.
not exist, maybe changed to crud.stub
?
// Declaration of
Prettus\Repository\Traits\CacheableRepository::paginate($limit = null, $columns = [...], $method = 'paginate')
// must be compatible with
Apiato\Core\Abstracts\Repositories\Repository::paginate($limit = null, $columns = [...], $method = 'paginate'): mixed
Description:
When iam call a view in ship (/app/ship/Views), shown View [parent] not found.. But if i place in (app/Ship/Mails/Templates/) has found.
Expected Behavior:
When in place resource views in folder /app/ship/Views must be found too.
Additional Context:
I had already fix this bugs with add the vendor apiato,
laravel-api/vendor/apiato/core/Loaders/ViewsLoaderTrait.php
add the new basePath loder with
base_path('app/Ship/Views/'); inside function loadViewsFromShip and load them
Versions:
Apiato Version: 10.x
PHP Version: 8
Steps To Reproduce:
Line 249 in ec6f445
I install a fresh apiato 12.
In .env:
php artisan test --testsuite Functional
and get error 404Tests work fine
private function buildUrlForUri($uri): string
{
/// Add this line to use api_prefix from .env file
$uri = Config::get('apiato.api.prefix') . $uri;
// add `/` at the beginning in case it doesn't exist
if (!Str::startsWith($uri, '/')) {
$uri = '/' . $uri;
}
return Config::get('apiato.api.url') . $uri;
}
Apiato EventServiceProvider (\Apiato\Core\Abstracts\Events\Dispatcher\Dispatcher) has been registered on ApiatoProvider boot method
https://github.com/apiato/core/blob/master/Providers/ApiatoProvider.php#L80
which cause the bug that Apiato Dispatcher is not available on DatabaseServiceProvider boot method https://github.com/illuminate/database/blob/master/DatabaseServiceProvider.php#L25
so instead the Apiato Dispatcher we are getting Illuminate\Events\Dispatcher
The solution will be to register Apiato EventServiceProvider before booting.
This issue is related with apiato/apiato#428
Inspired by #45, this is some sort of "What do you think" list of possible useful commands?
As there is already a apiato:actions
command, that list all available actions, why not do something like this:
apiato:list:actions
apiato:list:tasks
command that list all tasksapiato:list:dependencies
command from #45Any additional ideas?
Hi, I've shown you the FindContainerDependenciesCommand
on slack already and you gave me the following feedback:
The only problem is, if the user is injecting the command as dependency and not using the
call
function. I'd suggest simply adding a warning message when the command is executed to let users know about this.
I've since modified the command to now support both ways to call other scripts - Apiato::call('x@y')
and direct uses use App\Contianers\x
with two different regex versions. It also parses the container's composer.json
to provide more information (you might have two containers with the same name by different authors on different APIs).
My questions:
Apiato::call
methods?Current version:
Available in the following gist: https://gist.github.com/FWidm/f09aaa852a03e857eabf33990b2fb0af
Sample Output:
$ php artisan apiato:container-dependencies app/Containers/User/
Searching for dependencies in container: app/Containers/User/
Remove own container from listings? (y/n):
> y
Found dependencies:
[imports]:
[Authorization]:
[0]: app/Containers/User/Actions/CreateAdminAction.php
[1]: app/Containers/User/Data/Seeders/UserPermissionsSeeder_1.php
[2]: app/Containers/User/UI/API/Transformers/UserTransformer.php
[Authentication]:
[0]: app/Containers/User/Actions/DeleteUserAction.php
[1]: app/Containers/User/Actions/GetMyProfileAction.php
[Stripe]:
[0]: app/Containers/User/Models/User.php
Display Container author and description from the composer.json?(y/n):
> y
[name]: apiato/authorization
[description]: apiato/authorization
[name]: apiato/authentication
[description]: apiato/authentication
[name]: apiato/stripe
[description]: apiato/stripe
When running on PHP 8.1, hits to API endpoints will emit a warning that says:
explode(): Passing null to parameter #2 ($string) of type string is deprecated in /var/www/html/vendor/apiato/core/Traits /ResponseTrait.php on line 90
originating from this line in parseRequestedIncludes
function in ResponseTrait
:
Lines 88 to 91 in cbf2aca
Due to Request::get('include')
returning null and accepting null has been deprecated.
The same thing may happen to the function before it, since there's also a call to Request::get('filter')
and then the return value gets exploded in the following line.
Seems easy to fix, such as by adding ?? ''
to them, also maybe there are more places where Apiato calls explode on a possibly null/falsy value?
On container creation php artisan apiato:generate:container:
Generating Composer File
Container generated successfully.
Generating Composer File
Container already exists
no error expected
@johannesschobel do you have a mail where i can contact you
The ugly file
https://github.com/apiato/core/blob/master/Exceptions/ApiatoExceptionsHandler.php
Worth checking this as well
https://github.com/apiato/core/blob/master/Abstracts/Exceptions/Exception.php
If you run the php artisan apiato:generate:container:api
command several times, multiple migration files are generated. I already have an idea how to fix it - need time to implement it..
This is just a friendly reminder for myself in order to fix it ;)
@Mahmoudz can you please assign me to this task?
Expected to use hashid in search param but had to use real id
tested as admin on: {{url}}/v1/users?search=id:1 with HASH_ID=true in .env
PR #38 does the event handling properly (on dispatching) + removes the need for specifying the repository name (get's it from the container where the repository is located in). Please consider merging it
When The Model name is camel case, like NewItem, the database table is created as newitems, but when you try to call any query from a related Model, the table named as new_items.
if you try to use the relation function without specifying the table, you get error result. as the laravel will try to find the camelCase model class as new_items.
Easy to fix by declaring protected $table="newitems" in the model, and will work.
this should not be the case.
the migration generator should create table as new_items. to fix the problem.
so that we don't have to name the table in the model.
As you can see, apiato override tearDown
method
core/Abstracts/Tests/PhpUnit/TestCase.php
Line 54 in 571c6b2
I think, we don't need to refresh database, cause Illuminate\Foundation\Testing\TestCase
done with it, you can see at tearDown
method at Illuminate\Foundation\Testing\TestCase
PS: I have tried to test it (with remove tearDown
method in Apiato\Core\Abstracts\Tests\PhpUnit\TestCase
), and it work (using file or :memory
db)
Hi, you need to remove the namespace array item from Loaders\RoutesLoaderTrait.php in method getRouteGroup. Since you provide the wrong namespace, and actually it's a file path so it's a trigger bug. when I want in any route do this route::get('/test',TestCalls::class)
it will throw this exception UnexpectedValueException : Invalid route action:
The error message It is recommended to use the apiato caller style (containerName@className) for
gets really annoying and fills up the log, and we do not mind having containers "linked" (as this is the main reason i can see by reading docs http://docs.apiato.io/miscellaneous/magical-call/ for this call style). It would be good to have an option to turn off this and other future "nice to have" warning errors.
Maybe there's another way around this, but having some other error messages with warning, that do matter, changing log level app-wide is not an option. Maybe we should change this to debug/info level?
It happens that setupTestingUserAccess is not returning fresh copy of users with roles.
core/Traits/TestsTraits/PhpUnit/TestsAuthHelperTrait.php
Lines 171 to 179 in 0f02f4c
To make my test pass I had to change return $user;
to return $user->fresh();
8.7.x
8.2
Postgres
The controller generator is setting all new controllers to the containeraName
as the resource for the controller.
Say you have a container named Locations
and you have a model named District
(which is not the default model created on creating the container)
You run the create controller command.
The generated controller is pointing to the Locations
model (container name) yet it is supposed to point to the desired model. Its is doing so for the request
, resourceName
and transformer
.
This is the out come:
There is a problem with a "optimus/heimdal" when I try to install the core in my project with Laravel 6.
Problem 1
- Installation request for laravel/framework (locked at v6.0.0, required as ^6.0) -> satisfiable by laravel/framework[v6.0.0].
- apiato/core 2.4.7 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core 2.4.x-dev requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.0 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.1 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.2 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.3 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.4 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.5 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.6 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- apiato/core v2.4.8 requires optimus/heimdal ~1.5 -> satisfiable by optimus/heimdal[1.5.0].
- Conclusion: don't install optimus/heimdal 1.5.0
- Installation request for apiato/core ^2.4 -> satisfiable by apiato/core[2.4.7, 2.4.x-dev, v2.4.0, v2.4.1, v2.4.2, v2.4.3, v2.4.4, v2.4.5, v2.4.6, v2.4.8].
I did a fresh installation as mentioned in the documentation. I am able to navigate to apiato.test
and api.apito.test
. Till here everything is okay. As soon as I execute the command php artisan config:cache
api.apiato.test show the page of apiato.test and all the api's stop working
php artisan config:cache
should not impact the api working as this is common to execute this commad
Please let me know in case if I am missing something
Composer update is exexuted due to this error
Running composer update to apply merge settings
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework is locked to version v8.43.0 and an update of this package was not requested.
- league/flysystem 1.1.3 conflicts with roave/security-advisories dev-latest.
- laravel/framework v8.43.0 requires league/flysystem ^1.1 -> satisfiable by league/flysystem[1.1.3].
- Root composer.json requires roave/security-advisories dev-latest -> satisfiable by roave/security-advisories[dev-latest].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Update to apply merge settings failed, reverting ./composer.lock to its original content.
> @php artisan key:generate --ansi
Hi!, it is possible to disable a old api version
?
then set a redirect to a set up or active version,
sample,
the http://me.com/v1/test
is disabled, then it will redirect to http://me.com/v2/test
we know on line 155 have array
at $errors
argument
core/Abstracts/Exceptions/Exception.php
Line 155 in 571c6b2
but why still check (is_array
) at line 157 ?
core/Abstracts/Exceptions/Exception.php
Line 157 in 571c6b2
just asking...
Hello, I need to update laravel to v10 and already can not use apiato (require v9.x)
When can you update laravel version or help me pleade with use this package on v10.x
I think createTestingUser method does too much magic behind the scenes.
For example this line I don't think this is the best idea... Now in real tests you have to call $this->actingAs($user,'web')
in order to "disable" the linked line.
I expect the method to "create user" not "create and authenticate it". Or just make it protected so users (developers) can override.
8.7.0
8.2
No response
core/Abstracts/Requests/Request.php
Lines 128 to 140 in 149282f
This method triggers a "Call to a member function hasPermissionTo() on null" error if the middleware is removed from the Route, for example.
And if there is any value in the Permissions block in the Request.
I think the solution would be to check for the existence of $user in the closure before passing it to the anonymous function.
core/Abstracts/Requests/Request.php
Lines 137 to 139 in 149282f
So after this problem i've found #40 , i think this repo should have a code quality tool hooked up. As the apiato Ship container has a dependency of master repo, these kinds of errors should not slip through.
My Apiato App is running on Laradock. For testing, I use PhpStorm and ssh to laradock. Problem occurs because in my case $newFactoriesPath already has base_path() included and later it gets prepended again.
Had to change
core/Loaders/FactoriesLoaderTrait.php
Line 25 in 0f02f4c
$newFactoriesPath = str_replace_first(base_path(), '', $loadersDirectory) . '/FactoryMixer';
When calling an Action
or Task
by using Apiato::call('Container@ActionOrTask')
this fails to set the UI
correctly (is set to null
).
This is because of the CallableTrait::setUIIfExists()
..
This method tries to read property_exists($this, 'ui')
. However, in the context of calling it via Apiato::call()
, the $this
is Apiato
and not the corresponding container.. Therefore, this fails..
Not a major bug, but anyway ;)
core/Abstracts/Exceptions/Exception.php
Line 68 in ec6f445
Hi, it is possible to set authentication ($this->getTestingUser()
) with seeded user?
like this
$user = User::find($id);
$this->getTestingUser($user);
to test the specific role of possible access,
because the $this->getTestingUser();
is create fresh without any ralation on seeded data on other model
if (is_numeric($id)) {
throw new IncorrectIdException('Only Hashed ID's allowed' . (!is_null($parameter) ? " ($parameter)." : '.'));
}
this piece of code makes it impossible to decode "01" hash which is 6 in decimal.
https://github.com/apiato/core/blob/master/Traits/HashIdTrait.php#L195
I keep my images on aws s3, when user try to get image, he use api route
Route::get('files/{id}', [FindFileByIdController::class, 'findFileById'])
so next step I check access to file, if all good give a image,
Task => return Image::make(Storage::disk('s3')->get($file->path));
Controller =>
$file = app(FindFileByIdAction::class)->run($request);
return response(
$file->response(), 200,
[
'Content-Type' => $file->type,
'Content-Disposition' => "attachment; filename=" . $file->name .""
]);
But Content Type not changed, stay json and image broke, but i set a truth content type, can i resolve this problem?
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.