symfony 5.1 Bundle migration result in No mapping information to process - doctrine

I'm developing a Symfony 5.1 project under DDD, so I'm changing a bit all the default folders.
I have 2 bundles inside src folder and at the moment I only have entities inside one of them.
I generated the Entity User and its repository with the command make:user and then moved the files and changed namespaces, routes, configs, etc
When I run php bin/console make:migration I get an error "No mapping information to process"
$ run php bin/console make:migration -v
In NoMappingFound.php line 13:
[Doctrine\Migrations\Provider\Exception\NoMappingFound]
No mapping information to process
The folders are:
src
|-- Smartlink
|-- UserBundle/SmartlinkUserBundle.php
|-- Application
|-- Domain
| |-- Entity/User.php
| |-- interfaces/UserRepository.php
|-- Infrastructure
|-- Repository/MysqlUserRepository.php
The configuration is:
// composer.json
"autoload": {
"psr-4": {
"UserBundle\\": "src/Smartlink/UserBundle",
"SmartlinkBundle\\": "src/Smartlink/SmartlinkBundle",
"App\\": "src/"
}
},
===============================================
// config/bundles.php
return [
...
UserBundle\SmartlinkUserBundle::class => ['all' => true],
SmartlinkBundle\SmartlinkSmartlinkBundle::class => ['all' => true],
];
===============================================
// config/services.yaml
services:
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
UserBundle\:
resource: '../src/Smartlink/UserBundle/'
exclude:
- '../src/Smartlink/UserBundle/Domain/Entity/'
SmartlinkBundle\:
resource: '../src/Smartlink/SmartlinkBundle/'
exclude:
- '../src/Smartlink/SmartlinkBundle/Domain/Entity/'
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
- '../src/Tests/'
- '../src/Smartlink/'
===============================================
// config/routes/annotations.yaml
userbundle_controllers:
resource: ../../src/Smartlink/UserBundle/Infrastructure/Controller
type: annotation
smartlinkbundle_controllers:
resource: ../../src/Smartlink/SmartlinkBundle/Infrastructure/Controller
type: annotation
controllers:
resource: ../../src/Controller/
type: annotation
kernel:
resource: ../../src/Kernel.php
type: annotation
===============================================
// config/packages/doctrine.yaml
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
SmartlinkUserBundle:
is_bundle: true
type: annotation
dir: 'Domain/Entity'
alias: user_bundle
SmartlinkSmartlinkBundle:
is_bundle: true
type: annotation
dir: 'Domain/Entity'
alias: smartlink_bundle
The UserRepository is the same that generated the make:user command except for the namespace, which is changed to namespace UserBundle\Infrastructure\Repository; and the name that is changed to MysqlUserRepository that implements the interface UserRepository
And the entity User is
namespace UserBundle\Domain\Entity;
use UserBundle\Infrastructure\Repository\MysqlUserRepository;
/**
* #ORM\Entity(repositoryClass=MysqlUserRepository::class)
*/
class User implements UserInterface
{
...
I've been searching and all I have found is about symfony 2 and symfony 4, I tried the same that worked for the people who was asking, but still can't generate the migration of the bundles. what am I missing?
Edit: I changed some configurations and solved the UserBundle is not found or is not active but the main migration problem remains

Finally I found an answer, the solution is in the file config/packages/doctrine.yaml
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
SmartlinkUserBundle:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Smartlink/UserBundle/Domain/Entity' # 'Domain/Entity'
prefix: 'UserBundle\Domain\Entity'
alias: UserBundle
SmartlinkSmartlinkBundle:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Smartlink/SmartlinkBundle/Domain/Entity'
prefix: 'SmartlinkBundle\Domain\Entity'
alias: SmartlinkBundle
The fix is setting in_bundle to false
the dir: was wrong, so I had to fix it
and I added the prefix, without the prefix there was an error.
And now it works.

Related

Vue and spring boot with sub-path

How i can change sub-path from / to /new ?
If i do like this:
https://cli.vuejs.org/config/#publicpath
After this i get error becouse my static paths change from /static to /new/static in index.html:
but in project structure path doesn't change:
And becouse of it i get error in my site.
I need paths doesn't change in index.html how i can do it?
my vue.config.js :
Module.exports = {
devServer: {
server: 'https',
proxy: {
'/api': {
target: 'http://localhost:8098', // this configuration needs to correspond to the Spring Boot backends' application.properties server.port
ws: true,
changeOrigin: true
},
}
},
publicPath: '/new/',
outputDir: 'target/dist',
assetsDir: 'static',
}
My project from this fork:
https://github.com/jonashackt/spring-boot-vuejs
Help please

Symfony4: How to toggle entities using dotenv and multiple Entity Manager?

How it is possible through dotenv select different entity path with same name of entities.
Originally, We had application in Symfony 3 for people meetings on events of our organization. Then we decided to offer this application to our partners.
One of the partners asked us to customize the application for them with their data and specifications. We basically created a new instance of Symfony application with copy of database tables (with different prefix), changes in Entities to reflect new db table names, and some translation text changes.
It seems that other partners will follow this trend of customized instances.
Therefore, I am trying to update core application to Symfony 4 and I am trying to use multiple Entity Managers and dotenv to differentiate between partners database tables, as described bellow.
In a nutshell, I am trying to use multiple Entity Manager to switch db table names by prefix.
.env
###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=oci8://user:pass#127.0.0.1:1521/XE
EM_TYPE=OpenAccess
###< doctrine/doctrine-bundle ###
Only in security.yaml working env good
security:
encoders:
App\Entity\%env(EM_TYPE)%\Osoba:
providers:
our_db_provider:
entity:
class: App\Entity\%env(EM_TYPE)%\Osoba
property: username
When i tried get %env(EM_TYPE)% in default_entity_manager, then give error You have requested a non-existent service "doctrine.orm.%env(EM_TYPE)%_entity_manager". doctrine.yaml
parameters:
env(DATABASE_URL): ''
doctrine:
dbal:
default_connection: '%env(EM_TYPE)%'
connections:
MeetingTool:
driver: 'oci8'
charset: UTF8
schema_filter: /^MT_/
url: '%env(resolve:DATABASE_URL)%'
OpenAccess:
driver: 'oci8'
charset: UTF8
schema_filter: /^OA6_/
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
default_entity_manager: '%env(EM_TYPE)%'
entity_managers:
MeetingTool:
connection: MeetingTool
mappings:
Main:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/MeetingTool'
prefix: 'App\Entity\MeetingTool'
alias: App2
OpenAccess:
connection: OpenAccess
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/OpenAccess'
prefix: 'App\Entity\OpenAccess'
alias: OpenAccess
and biggest problem is use, how i targeting right entity here? for example loginController.php
<?php
namespace App\Controller;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\OpenAccess\LogPrihlaseni;
//use App\Entity\MeetingTool\LogPrihlaseni;
class LoginController extends AbstractController {
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
public function logPrihlaseni() {
$log = new LogPrihlaseni();

Symfony 3 | JMSi18nRoutingBundle exclude SonataMediaBundle routes

Guys I use JMSi18nRoutingBundle with some JMS bundles too, so I wanted to exclude sonata media routes, so i tried : i18n = false
by this code
media:
resource: '#SonataMediaBundle/Resources/config/routing/media.xml'
prefix: /media
options: { i18n: false }
also i tried:
media:
resource: '#SonataMediaBundle/Resources/config/routing/media.xml'
prefix: /media
options:
i18n: false
but i still got the links like this:
http://mysite.local/app_dev.php/en/uploads/media/Slider/0001/03/405f4n41adb162399344690cf85143c52a0ed147.jpeg

webpack 2 + extract-text-webpack-plugin: parsing errors

I'm trying to make a webpack config for my project with some scss. Some of it comes from the root project and some scss I want to load from dependencies e.g. from node_modules. I'm running into a strange error where if I don't include the node_modules in the module, it get's built including some scss that I have in the root project. But if I add include: path.resolve(__dirname, 'node_modules') or any other folder (eve one that doesn't exist) it fails but on file that is in root project and not in node_modules, the same files that it was extracting before with no errors.
Here is the webpack config:
const extractCSS = new ExtractTextPlugin({ filename: 'style.css', disable: false, allChunks: true });
module: {
rules: [
{
test: /\.scss$/,
include: path.resolve(__dirname, 'node_modules'),
use:extractCSS.extract({
fallbackLoader: 'style-loader',
loader: ['css-loader', 'sass-loader'],
})
},
]
}
So if I comment out the line with include it works but doesn't include node_modules and if I leave the line uncommented I get the error:
Unexpected character '#' (1:0) You may need an appropriate loader to handle this file type. in all of the scss files that are in the root project.
What am I doing wrong?

In codeception functional test seeInDatabase not works from laravel

I am using codeception for testing in laravel 5.2.
Here is my codeception.yml file:
actor: Tester
paths:
tests: tests_codecept
log: tests_codecept/_output
data: tests_codecept/_data
support: tests_codecept/_support
envs: tests_codecept/_envs
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=kartice_test'
user: '*******'
password: '*******'
dump: tests_codecept/_data/dump.sql
populate: true
cleanup: true
reconnect: true
and here is functional.suite.yml file:
class_name: FunctionalTester
modules:
enabled:
# add framework module here
- \Helper\Functional
- Asserts
- Laravel5:
environment_file: .env.testing
- Db
here is my test method:
public function provera_dodavanja_novog_klijenta(FunctionalTester $I)
{
$this->authenticate($I);
$I->amOnPage('/kancelarija/komitenti/create');
$I->see('Kreiranje novog komitenta');
$I->fillField('input[name=komitent_code]', 'kom1');
$I->fillField('input[name=komitent_name]', 'Komitent 1');
$I->click('btnSave');
$I->seeInDatabase('komitenti', ['code' => 'kom1', 'name' => 'Komitent 1']);
$I->see('Komitent Komitent 1 je uspešno kreiran.');
}
Running functional test fails with message:
Step I see in database "komitenti",{"code":"kom1","name":"Komitent 1"}
Fail No matching records found for criteria {"code":"kom1","name":"Komitent 1"} in table komitenti
Failed asserting that 0 is greater than 0.
What I am doing wrong?
I have seen question Codeception seeInDatabase() doesn't work for me but this didn't helpe me.
You should probably useseeRecord method instead of seeInDatabase. I don't know why but for me first one was working and second one - not.
I use gulp tdd and when testing forms come across this error.
Please check:
You added this to Requests
<YourFormRequest>use App\Http\Requests\<YourFormRequest>;
Ensure the Model for your table is mass assignable
protected $fillable = ['tableField1', 'tableField2']

Resources