Laravel jsonapi routes
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 15
- Joined: 05 Apr 2018, 10:26
Laravel jsonapi routes
Hello!
If I add an item to my basket, the basket icon on the upper right corner was not updated.
I looked into that issue and apperently all jsonapi requests are not working.
I get the following error message:
If I add the following code to my normal laravel route file, the jsonapi OPTIONS is working.
Unfortunately it only works with the OPTIONS and not for the other get requests...
This is not working.
How can I get the jsonapi to work properly?
Did I miss some configuration options?
If I add an item to my basket, the basket icon on the upper right corner was not updated.
I looked into that issue and apperently all jsonapi requests are not working.
I get the following error message:
Code: Select all
ReflectionException
Class api does not exist
in Container.php (line 729)
at ReflectionClass->__construct('api')
in Container.php (line 729)
at Container->build('api')
in Container.php (line 608)
at Container->resolve('api')
in Container.php (line 575)
at Container->make('api')
in Application.php (line 728)
at Application->make('api')
in Pipeline.php (line 138)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in Pipeline.php (line 102)
at Pipeline->then(object(Closure))
in Router.php (line 574)
at Router->runRouteWithinStack(object(Route), object(Request))
in Router.php (line 533)
at Router->dispatchToRoute(object(Request))
in Router.php (line 511)
at Router->dispatch(object(Request))
in Kernel.php (line 176)
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
in Pipeline.php (line 30)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in LogLastUserActivity.php (line 25)
at LogLastUserActivity->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in VerifyCsrfToken.php (line 65)
at VerifyCsrfToken->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in ShareErrorsFromSession.php (line 49)
at ShareErrorsFromSession->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in Language.php (line 35)
at Language->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in StartSession.php (line 64)
at StartSession->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in AddQueuedCookiesToResponse.php (line 37)
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in EncryptCookies.php (line 59)
at EncryptCookies->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in CheckForMaintenanceMode.php (line 46)
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->Illuminate\Routing\{closure}(object(Request))
in Pipeline.php (line 102)
at Pipeline->then(object(Closure))
in Kernel.php (line 151)
at Kernel->sendRequestThroughRouter(object(Request))
in Kernel.php (line 116)
at Kernel->handle(object(Request))
in index.php (line 53)
Code: Select all
Route::match( array( 'OPTIONS' ), 'jsonapi', array(
'as' => 'aimeos_shop_jsonadm_options',
'uses' => '\Aimeos\Shop\Controller\JsonadmController@optionsAction'
))->where( array( 'resource' => '[^0-9A-Z\-\_]*' ) );
This is not working.
Code: Select all
Route::match( array( 'GET' ), 'jsonapi/{resource}', array(
'as' => 'aimeos_shop_jsonapi_get',
'uses' => '\Aimeos\Shop\Controller\JsonapiController@getAction'
));
How can I get the jsonapi to work properly?
Did I miss some configuration options?
Re: Laravel jsonapi routes
Which Aimeos version and environment are you using?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 15
- Joined: 05 Apr 2018, 10:26
Re: Laravel jsonapi routes
I have installed Aimeos 2017.10.2 in my existing Laravel 5.4 project.
It is running with PHP 7.1.12 on a Mac.
It is running with PHP 7.1.12 on a Mac.
Re: Laravel jsonapi routes
Our Laravel 5.4 test installation runs well with Aimeos 2017.10.2. Did you set up the admin interface too? The code for the boot() method in app/Providers/AuthServiceProvider.php might be required for the JSON REST API as well:
https://github.com/aimeos/aimeos-laravel#admin
https://github.com/aimeos/aimeos-laravel#admin
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 15
- Joined: 05 Apr 2018, 10:26
Re: Laravel jsonapi routes
I already set up the admin interface before. Changing the code in the boot changed nothing.
Do you have any other idea?
Do you have any other idea?
Re: Laravel jsonapi routes
Not really. Maybe something from your existing code interferes with the Aimeos routes. You can use
to see all available routes. In my Laravel 5.4 installation this looks like:
The "composer show" command returns:
Please note that Aimeos 2017.10.4 is the latest version and you also should have installed the latest Laravel 5.4.* version.
Code: Select all
./artisan route:list
Code: Select all
+--------+---------------+---------------------------------------------------------------------------+------------------------------+------------------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+---------------+---------------------------------------------------------------------------+------------------------------+------------------------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | admin | aimeos_shop_admin | Aimeos\Shop\Controller\AdminController@indexAction | web |
| | POST | admin/{site}/extadm/do | aimeos_shop_extadm_json | Aimeos\Shop\Controller\ExtadmController@doAction | web,auth |
| | GET|HEAD | admin/{site}/extadm/file | aimeos_shop_extadm_file | Aimeos\Shop\Controller\ExtadmController@fileAction | web,auth |
| | GET|HEAD | admin/{site}/extadm/{lang?}/{tab?} | aimeos_shop_extadm | Aimeos\Shop\Controller\ExtadmController@indexAction | web,auth |
| | GET|POST|HEAD | admin/{site}/jqadm/copy/{resource}/{id} | aimeos_shop_jqadm_copy | Aimeos\Shop\Controller\JqadmController@copyAction | web,auth |
| | GET|POST|HEAD | admin/{site}/jqadm/create/{resource} | aimeos_shop_jqadm_create | Aimeos\Shop\Controller\JqadmController@createAction | web,auth |
| | GET|POST|HEAD | admin/{site}/jqadm/delete/{resource}/{id} | aimeos_shop_jqadm_delete | Aimeos\Shop\Controller\JqadmController@deleteAction | web,auth |
| | GET|POST|HEAD | admin/{site}/jqadm/export/{resource} | aimeos_shop_jqadm_export | Aimeos\Shop\Controller\JqadmController@exportAction | web,auth |
| | GET|HEAD | admin/{site}/jqadm/file/{type} | aimeos_shop_jqadm_file | Aimeos\Shop\Controller\JqadmController@fileAction | web,auth |
| | GET|HEAD | admin/{site}/jqadm/get/{resource}/{id} | aimeos_shop_jqadm_get | Aimeos\Shop\Controller\JqadmController@getAction | web,auth |
| | GET|POST|HEAD | admin/{site}/jqadm/import/{resource} | aimeos_shop_jqadm_import | Aimeos\Shop\Controller\JqadmController@importAction | web,auth |
| | POST | admin/{site}/jqadm/save/{resource} | aimeos_shop_jqadm_save | Aimeos\Shop\Controller\JqadmController@saveAction | web,auth |
| | GET|POST|HEAD | admin/{site}/jqadm/search/{resource} | aimeos_shop_jqadm_search | Aimeos\Shop\Controller\JqadmController@searchAction | web,auth |
| | OPTIONS | admin/{site}/jsonadm/{resource?} | aimeos_shop_jsonadm_options | Aimeos\Shop\Controller\JsonadmController@optionsAction | web,auth |
| | DELETE | admin/{site}/jsonadm/{resource}/{id?} | aimeos_shop_jsonadm_delete | Aimeos\Shop\Controller\JsonadmController@deleteAction | web,auth |
| | PATCH | admin/{site}/jsonadm/{resource}/{id?} | aimeos_shop_jsonadm_patch | Aimeos\Shop\Controller\JsonadmController@patchAction | web,auth |
| | POST | admin/{site}/jsonadm/{resource}/{id?} | aimeos_shop_jsonadm_post | Aimeos\Shop\Controller\JsonadmController@postAction | web,auth |
| | PUT | admin/{site}/jsonadm/{resource}/{id?} | aimeos_shop_jsonadm_put | Aimeos\Shop\Controller\JsonadmController@putAction | web,auth |
| | GET|HEAD | admin/{site}/jsonadm/{resource}/{id?} | aimeos_shop_jsonadm_get | Aimeos\Shop\Controller\JsonadmController@getAction | web,auth |
| | GET|POST|HEAD | basket | aimeos_shop_basket | Aimeos\Shop\Controller\BasketController@indexAction | web |
| | GET|POST|HEAD | checkout | aimeos_shop_checkout | \Aimeos\Shop\Controller\CheckoutController@indexAction | web |
| | GET|POST|HEAD | checkout/{c_step?} | aimeos_shop_checkout | Aimeos\Shop\Controller\CheckoutController@indexAction | web |
| | GET|POST|HEAD | confirm/{code?} | aimeos_shop_confirm | Aimeos\Shop\Controller\CheckoutController@confirmAction | web |
| | GET|POST|HEAD | count | aimeos_shop_count | Aimeos\Shop\Controller\CatalogController@countAction | web |
| | GET|POST|HEAD | detail/pin/{pin_action?}/{pin_id?}/{d_prodid?}/{d_name?}/{d_pos?} | aimeos_shop_session_pinned | Aimeos\Shop\Controller\CatalogController@detailAction | web |
| | GET|POST|HEAD | detail/{d_prodid}/{d_name?}/{d_pos?} | aimeos_shop_detail | Aimeos\Shop\Controller\CatalogController@detailAction | web |
| | GET|HEAD | home | | App\Http\Controllers\HomeController@index | web,auth |
| | OPTIONS | jsonapi/{resource?} | aimeos_shop_jsonapi_options | Aimeos\Shop\Controller\JsonapiController@optionsAction | web,api |
| | DELETE | jsonapi/{resource} | aimeos_shop_jsonapi_delete | Aimeos\Shop\Controller\JsonapiController@deleteAction | web,api |
| | GET|HEAD | jsonapi/{resource} | aimeos_shop_jsonapi_get | Aimeos\Shop\Controller\JsonapiController@getAction | web,api |
| | PATCH | jsonapi/{resource} | aimeos_shop_jsonapi_patch | Aimeos\Shop\Controller\JsonapiController@patchAction | web,api |
| | POST | jsonapi/{resource} | aimeos_shop_jsonapi_post | Aimeos\Shop\Controller\JsonapiController@postAction | web,api |
| | PUT | jsonapi/{resource} | aimeos_shop_jsonapi_put | Aimeos\Shop\Controller\JsonapiController@putAction | web,api |
| | GET|POST|HEAD | list | aimeos_shop_list | Aimeos\Shop\Controller\CatalogController@listAction | web |
| | GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest |
| | POST | login | | App\Http\Controllers\Auth\LoginController@login | web,guest |
| | POST | logout | logout | App\Http\Controllers\Auth\LoginController@logout | web |
| | GET|POST|HEAD | myaccount | aimeos_shop_account | Aimeos\Shop\Controller\AccountController@indexAction | web,auth |
| | GET|POST|HEAD | myaccount/download/{dl_id} | aimeos_shop_account_download | Aimeos\Shop\Controller\AccountController@downloadAction | web,auth |
| | GET|POST|HEAD | myaccount/favorite/{fav_action?}/{fav_id?}/{d_prodid?}/{d_name?}/{d_pos?} | aimeos_shop_account_favorite | Aimeos\Shop\Controller\AccountController@indexAction | web,auth |
| | GET|POST|HEAD | myaccount/watch/{wat_action?}/{wat_id?}/{d_prodid?}/{d_name?}/{d_pos?} | aimeos_shop_account_watch | Aimeos\Shop\Controller\AccountController@indexAction | web,auth |
| | POST | password/email | password.email | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest |
| | GET|HEAD | password/reset | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\ResetPasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token} | password.reset | App\Http\Controllers\Auth\ResetPasswordController@showResetForm | web,guest |
| | GET|HEAD | privacy | aimeos_shop_privacy | Aimeos\Shop\Controller\PageController@privacyAction | |
| | GET|HEAD | register | register | App\Http\Controllers\Auth\RegisterController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\RegisterController@register | web,guest |
| | GET|POST|HEAD | stock | aimeos_shop_stock | Aimeos\Shop\Controller\CatalogController@stockAction | web |
| | GET|POST|HEAD | suggest | aimeos_shop_suggest | Aimeos\Shop\Controller\CatalogController@suggestAction | web |
| | GET|HEAD | terms | aimeos_shop_terms | Aimeos\Shop\Controller\PageController@termsAction | |
| | GET|POST|HEAD | update | aimeos_shop_update | Aimeos\Shop\Controller\CheckoutController@updateAction | |
+--------+---------------+---------------------------------------------------------------------------+------------------------------+------------------------------------------------------------------------+------------+
Code: Select all
aimeos/ai-admin-extadm 2017.10.1 Aimeos ai-admin-extadm extension
aimeos/ai-admin-jqadm 2017.10.20 Aimeos ai-admin-jqadm extension
aimeos/ai-admin-jsonadm 2017.10.5 Aimeos ai-admin-jsonadm extension
aimeos/ai-client-html 2017.10.9 Aimeos ai-client-html extension
aimeos/ai-client-jsonapi 2017.10.3 Aimeos JSON API extension
aimeos/ai-controller-frontend 2017.10.5 Aimeos ai-controller-frontend extension
aimeos/ai-controller-jobs 2017.10.4 Aimeos ai-controller-jobs extension
aimeos/ai-gettext 2017.10.1 Aimeos Gettext extension
aimeos/ai-laravel 2017.10.1 Laravel adapter for Aimeos web shops and e-commerce solu...
aimeos/ai-payments 2017.10.2 Payment extension for Aimeos web shops and e-commerce so...
aimeos/ai-swiftmailer 2017.10.5 SwiftMailer adapter for Aimeos web shops and e-commerce ...
aimeos/aimeos-core 2017.10.15 Full-featured e-commerce components for high performance...
aimeos/aimeos-laravel 2017.10.4 Full-featured Laravel web shop package and e-commerce so...
composer/installers v1.5.0 A multi-framework Composer library installer
dnoegel/php-xdg-base-dir 0.1 implementation of xdg base directory specification for php
doctrine/annotations v1.4.0 Docblock Annotations Parser
doctrine/cache v1.6.2 Caching library offering an object-oriented API for many...
doctrine/collections v1.4.0 Collections Abstraction library
doctrine/common v2.7.3 Common Library for Doctrine projects
doctrine/dbal v2.5.13 Database Abstraction Layer
doctrine/inflector v1.2.0 Common String Manipulations with regard to casing and si...
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in P...
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, R...
erusev/parsedown 1.7.1 Parser for Markdown.
fzaninotto/faker v1.7.1 Faker is a PHP library that generates fake data for you.
guzzle/guzzle v3.9.3 PHP HTTP client. This library is deprecated in favor of ...
hamcrest/hamcrest-php v1.2.2 This is the PHP port of Hamcrest Matchers
jakub-onderka/php-console-color 0.1
jakub-onderka/php-console-highlighter v0.3.2
laravel/framework v5.4.36 The Laravel Framework.
laravel/tinker v1.0.5 Powerful REPL for the Laravel framework.
league/flysystem 1.0.44 Filesystem abstraction: Many filesystems, one API.
mockery/mockery 0.9.9 Mockery is a simple yet flexible PHP mock object framewo...
monolog/monolog 1.23.0 Sends your logs to files, sockets, inboxes, databases an...
mtdowling/cron-expression v1.2.1 CRON for PHP: Calculate the next or previous run date an...
myclabs/deep-copy 1.7.0 Create deep copies (clones) of your objects
nesbot/carbon 1.25.0 A simple API extension for DateTime.
nikic/php-parser v3.1.5 A PHP parser written in PHP
omnipay/authorizenet 2.5.1 Authorize.Net gateway for the Omnipay payment processing...
omnipay/cardsave 2.1.2 CardSave driver for the Omnipay payment processing library
omnipay/common 2.5.2 Common components for Omnipay payment processing library
omnipay/mollie v3.2.0 Mollie driver for the Omnipay payment processing library
omnipay/paypal v2.6.4 PayPal gateway for Omnipay payment processing library
omnipay/sagepay 2.5.1 Sage Pay driver for the Omnipay PHP payment processing l...
omnipay/stripe V2.4.7 Stripe driver for the Omnipay payment processing library
paragonie/random_compat v2.0.12 PHP 5.x polyfill for random_bytes() and random_int() fro...
phpdocumentor/reflection-common 1.0.1 Common reflection classes used by phpdocumentor to refle...
phpdocumentor/reflection-docblock 4.3.0 With this component, a library can provide support for a...
phpdocumentor/type-resolver 0.4.0
phpspec/prophecy 1.7.5 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage 4.0.8 Library that provides collection, processing, and render...
phpunit/php-file-iterator 1.4.5 FilterIterator implementation that filters files based o...
phpunit/php-text-template 1.2.1 Simple template engine.
phpunit/php-timer 1.0.9 Utility class for timing
phpunit/php-token-stream 2.0.2 Wrapper around PHP's tokenizer extension.
phpunit/phpunit 5.7.27 The PHP Unit Testing framework.
phpunit/phpunit-mock-objects 3.4.4 Mock Object library for PHPUnit
psr/http-message 1.0.1 Common interface for HTTP messages
psr/log 1.0.2 Common interface for logging libraries
psy/psysh v0.8.18 An interactive shell for modern PHP.
ramsey/uuid 3.7.3 Formerly rhumsaa/uuid. A PHP 5.4+ library for generating...
sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to
sebastian/comparator 1.2.4 Provides the functionality to compare PHP values for equ...
sebastian/diff 1.4.3 Diff implementation
sebastian/environment 2.0.0 Provides functionality to handle HHVM/PHP environments
sebastian/exporter 2.0.0 Provides the functionality to export PHP variables for v...
sebastian/global-state 1.1.1 Snapshotting of global state
sebastian/object-enumerator 2.0.1 Traverses array structures and object graphs to enumerat...
sebastian/recursion-context 2.0.0 Provides functionality to recursively process PHP variables
sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate o...
sebastian/version 2.0.1 Library that helps with managing the version number of G...
swiftmailer/swiftmailer v5.4.9 Swiftmailer, free feature-rich PHP mailer
symfony/console v3.4.7 Symfony Console Component
symfony/css-selector v3.4.7 Symfony CssSelector Component
symfony/debug v3.4.7 Symfony Debug Component
symfony/event-dispatcher v2.8.37 Symfony EventDispatcher Component
symfony/finder v3.4.7 Symfony Finder Component
symfony/http-foundation v3.4.7 Symfony HttpFoundation Component
symfony/http-kernel v3.4.7 Symfony HttpKernel Component
symfony/polyfill-mbstring v1.7.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php70 v1.7.0 Symfony polyfill backporting some PHP 7.0+ features to l...
symfony/process v3.4.7 Symfony Process Component
symfony/psr-http-message-bridge v1.0.2 PSR HTTP message bridge
symfony/routing v3.4.7 Symfony Routing Component
symfony/translation v3.4.7 Symfony Translation Component
symfony/var-dumper v3.4.7 Symfony mechanism for exploring and dumping PHP variables
symfony/yaml v3.4.7 Symfony Yaml Component
tijsverkoyen/css-to-inline-styles 2.2.1 CssToInlineStyles is a class that enables you to convert...
vdbelt/omnipay-oppwa 1.1
vlucas/phpdotenv v2.4.0 Loads environment variables from `.env` to `getenv()`, `...
webmozart/assert 1.3.0 Assertions to validate method input/output with nice err...
zendframework/zend-diactoros 1.7.1 PSR HTTP Message implementations
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 15
- Joined: 05 Apr 2018, 10:26
Re: Laravel jsonapi routes
I fixed it.
The project was not started with Laravel 5.4, so the api middlewareGroup was missing in the Kernel.php file.
Thank you very much for your help!
The project was not started with Laravel 5.4, so the api middlewareGroup was missing in the Kernel.php file.
Code: Select all
protected $middlewareGroups = [
'web' => [
],
'api' => [
],
];