Sylius Customizing Models with error class not found in namespaces - sylius

I followed the guideline on Sylius site for customizing models:
http://docs.sylius.com/en/1.0/customization/model.html
When I run:
php bin/console doctrine:schema:update --force
or
php bin/console doctrine:migrations:diff
Error: The class 'AppBundle\Entity\Country' was not found in the chain configured namespaces
Files added at:
\src\AppBundle\Entity\Country.php
\src\AppBundle\Resources\config\doctrine\Country.orm.yml
Added:
sylius_addressing:
resources:
country:
classes:
model: AppBundle\Entity\Country
at:
\app\config\config.yml
And doctrine related settings on config.yml as below:
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
server_version: "5.5"
charset: UTF8
doctrine_migrations:
dir_name: "%kernel.root_dir%/migrations"
namespace: Sylius\Migrations
table_name: sylius_migrations
name: Sylius Migrations
Country.php
<?php
namespace AppBundle\Entity;
use Sylius\Component\Addressing\Model\Country as BaseCountry;
class Country extends BaseCountry
{
private $flag;
public function getFlag(): ?bool
{
return $this->flag;
}
public function setFlag(bool $flag): void
{
$this->flag = $flag;
}
}
(Sylius 1.0 installed on Windows 7)
Tried clear cache and many other methods but no clues.

You have an indentation error in config.yml, it should be:
sylius_addressing:
resources:
country:
classes:
model: AppBundle\Entity\Country
(you haven't tab symbol before country)

Thanks, but just check again, the tab already included.
YAML forbid tabs. Use 2 or 4 spaces instead. See here

I have installed latest version (1.1.6) and it works!
So, should be a bug on 1.0.0 version...

Related

How to enable swagger UI on micronaut?

I'm following the micronaut doc for openapi at https://micronaut-projects.github.io/micronaut-openapi/latest/guide/
and the UI is not being generated, every time when I try to access /swagger, /swagger-ui I got this error:
{
"message": "Not Found",
"_links": {
"self": {
"href": "/swagger",
"templated": false
}
},
"_embedded": {
"errors": [
{
"message": "Page Not Found"
}
]
}
}
The dependencies are installed:
implementation("io.swagger.core.v3:swagger-annotations")
annotationProcessor("io.micronaut.openapi:micronaut-openapi:4.5.2")
The router on application.yml is defined:
micronaut:
application:
name: myapp
router:
static-resources:
default:
enabled: true
swagger:
enabled: true
paths: classpath:META-INF/swagger
mapping: /swagger/**
and the file openapi.properties on the root folder is created:
swagger-ui.enabled=true
micronaut.openapi.views.spec=apidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop
micronaut.openapi.expand.api.version=v0.1
micronaut.openapi.expand.openapi.description=myapp
according to the docs a .yml file should be generated at;
For Kotlin build/tmp/kapt3/classes/main/META-INF/swagger/myapp-0.1.yml
On my controllers I have the Operation and ApiResponses annotation as well, but when I run the application the file yml is not being generated, how can I properly enable swagger on my micronaut project?
Code sample: https://github.com/rafa-acioly/micronaut
You defined only swagger in your application.yml. You should add also add a section for swagger-ui with a similar definition:
micronaut:
application:
name: openapitest
router:
static-resources:
swagger:
paths: classpath:META-INF/swagger
mapping: /swagger/**
swagger-ui:
paths: classpath:META-INF/swagger/views/swagger-ui
mapping: /swagger-ui/**
Also, I used the default openapi.properties file:
swagger-ui.enabled=true
redoc.enabled=false
rapidoc.enabled=false
rapidoc.bg-color=#14191f
rapidoc.text-color=#aec2e0
rapidoc.sort-endpoints-by=method
And did you try to clean and build your project with gradlew?
I create a sample repository on GitHub and you can check it.
=========UPDATE========
Ok, I've found what is incorrect! You are using annotation-processing :
annotationProcessor("io.micronaut.openapi:micronaut-openapi:4.5.2")
But if you are using Kotlin, you should use kapt - Kotlin Annotation Processing Tool. Here is a few articles - link1, link2.
So you should change to:
kapt("io.micronaut.openapi:micronaut-openapi:4.5.2")

Issues creating Admin module controller on Prestashop

The controller for URI "/modules/mm_custom/deleter" is not callable. Class "Mm_Custom\Controller\ConfigureController" does not exist.
[InvalidArgumentException 0]
That's what I get after 3 days trying to set an AdminController on my Prestashop module.
Here is the controller "configureController.php":
<?php
// modules/mm_custom/src/controller/configureController.php
namespace Mm_Custom\Controller;
use Symfony\Component\HttpFoundation\Response;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
class ConfigureController extends FrameworkBundleAdminController
{
public function deleteAction()
{
return new Response('Hello');
}
}
Here is the routes.yml :
# modules/mm_custom/config/routes.yml
delete:
path: mm_custom/deleter
methods: [GET]
defaults:
_controller: 'Mm_Custom\Controller\ConfigureController::deleteAction'
Here is the composer.json at the module folder root:
{
"name": "sixten/mm_custom",
"description": "A tool developped to allow your customers to easily and efficiently custom your product.",
"autoload": {
"psr-4": {
"Mm_Custom\\Controller\\": "src/Controller/"
}
},
"config": {
"prepend-autoloader": false
},
"type": "prestashop-module"
}
If the problem is not from a mistake in the code himself, it might comes from the fact that I couldn't run the composer dumpautoload console command in the module's folder directly because the website is online on a ftp server.
I put the composer.json somewhere else on my computer, ran the command and copy/paste the composer.json and the vendor file I get in the ftp's module folder. Maybe it's not the good way to do it ?
Thanks for reading me !

"error": "Could not connect to websocket endpoint ws://localhost:8000/subscriptions. Please check if the endpoint url is correct." for graphql spqr

I have my data stored in mongodb and I'm trying to implemet subscription using graphql spqr and project reactive.
I'm getting respones for when I'm trying to test mutations and query, but I keep on getting the following error message for subsctiptions:
{ "error": "Could not connect to websocket endpoint
ws://localhost:8080/subscriptions. Please check if the endpoint url is
correct." }
I've done some reserch on this issue and came accross this, including "spring-boot-starter-websocket" in my dependencies didn't solve this, anf I'm not using firefox as my browser for the playground gui.
I followed this example on how to implement subscriptions using graphql spqr, and when I trying to clone the project the subscription actualy worked just fine.
Can't fine any difference on my implementation from the project above...
Here is my build.gradle file:
configurations {
compile.exclude module: 'spring-boot-starter-tomcat'
compile.exclude group: 'org.apache.tomcat'
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
// https://mvnrepository.com/artifact/de.flapdoodle.embed/de.flapdoodle.embed.mongo
testImplementation group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '3.0.0'
// https://mvnrepository.com/artifact/io.leangen.graphql/graphql-spqr-spring-boot-starter
implementation group: 'io.leangen.graphql', name: 'graphql-spqr-spring-boot-starter', version: '0.0.6'
implementation group: 'io.leangen.graphql', name: 'spqr', version: io_leangen_graphql_spqr
// https://mvnrepository.com/artifact/com.graphql-java-kickstart/playground-spring-boot-starter
implementation group: 'com.graphql-java-kickstart', name: 'playground-spring-boot-starter', version: '11.1.0'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-websocket
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-websocket', version: '2.5.4'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-mongodb-reactive
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-mongodb-reactive', version: '2.5.4'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-webflux
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.5.4'
compileOnly group: 'org.projectlombok', name: 'lombok', version: org_projectlombok_lombok_version
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: org_projectlombok_lombok_version
}
I'm using
compile.exclude module: 'spring-boot-starter-tomcat'
compile.exclude group: 'org.apache.tomcat'
To start netty instead of tomcat
And here is my subsctiption implementation:
#Autowired
private ProductRepository productRepository;
private final ConcurrentMultiMap<Double, FluxSink<ProductDto>> subscribers = new ConcurrentMultiMap<>();
#GraphQLQuery
public Flux<ProductDto> getProducts(){
return productRepository.findAll().map(AppUtils::ProductEntityToDto);
}
#GraphQLSubscription
public Publisher<ProductDto> taskStatusChanged(double price) {
return Flux.create(subscriber -> subscribers.add(price, subscriber.onDispose(() -> subscribers.remove(price, subscriber))), FluxSink.OverflowStrategy.LATEST);
}
Is there something I'm missing in my code? Or a dependancy? Or any other configuration? Any help would be very appreciated...
By default it seems GraphQl SPQR mapped the WebSocket subscription handling endpoint to /graphql, not the general /subscriptions in other GraphQL framework.
See the following info in console when the application is starting.
2021-10-09 12:50:02.653 DEBUG 14632 --- [ Test worker] o.s.w.s.s.s.WebSocketHandlerMapping : Patterns [/graphql] in 'webSocketHandlerMapping'
It can be changed by customizing graphql.spqr.ws.endpoint property in your application.properties.
But it seems its GraphQL WebSocket subscription implementation is very confused, it does not follow the Appllo WebSocket subscription protocol or the new graphql-ws spec.

Codeception: Class "tests\_support\AcceptanceTester" does not exist

New to PHP and Codeception, but not to programming. I've just set up Codeception in my web site's root folder.
During the install, I ran:
php vendor/bin/codecept bootstrap
and
php vendor/bin/codecept build
My _support/AcceptanceTester.php contains this:
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}
and acceptance.suite.yaml has this:
actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost/shop
- \Helper\Acceptance
step_decorators: ~
What am I missing???

TypeORM with React Native

I created a new dummy app with react-native init test, and then followed the instructions to add typeorm. In my App.js I included import {getManager} from 'typeorm', and then ran react-native run-ios.
I see the following error in metro-bundler:
Error: Unable to resolve module path from /Users/amit/Code/test/node_modules/typeorm/platform/PlatformTools.js: Module path does not exist in the Haste module map
Here's a sample repository to show the problem: enter link description here
Not sure if I missed something in the setup! Any help is really welcome!
Unfortunately import from 'typeorm' module does not work because react-native projects does not use node platform excatly. Imports from 'typeorm/browser' will work. Here is a sample project.: https://github.com/typeorm/react-native-example
Make sure you create a connection object that does not use any references to project file system. Avoid using something like:
import { CountSession } from '../biopro-mobile-database/entities/count_session';
const connection = await createConnection({
name: 'liteDb_3',
type: 'react-native',
database: 'biopro_mobile.sqlite',
location: 'default',
synchronize: false,
logging: true,
entities: ["../biopro-mobile-database/entities/**/*.ts"],
})
Avoid entities: ["../biopro-mobile-database/entities//*.ts"],**
Instead use something like:
import { EquipmentCounted } from '../biopro-mobile-database/entities/equipment_counted';
import { CountSession } from '../biopro-mobile-database/entities/count_session';
const connection = await createConnection({
name: 'liteDb_3',
type: 'react-native',
database: 'biopro_mobile.sqlite',
location: 'default',
synchronize: false,
logging: true,
entities: [
CountSession,
EquipmentCounted,
],
})