sonatabundle installation ApplicationSonataMediaBundle not found - symfony

I tried to follow the tutorial installation for SonataBundle tutorial
I change only mapping in this way
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
types:
json: Sonata\Doctrine\Types\JsonType
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
ApplicationSonataMediaBundle: ~
SonataMediaBundle: ~
the command
php app/console sonata:easy-extends:generate --dest=src SonataMediaBundle
generate in src/Application/Sonata/MediaBundle/ApplicationSonataMediaBundle
but always I get this error :
Class 'Application\Sonata\MediaBundle\ApplicationSonataMediaBundle' not found

Related

Symfony4 doctrine utf8mb4 not detected

i have an issue with doctrine and symfony4.1, he don't take my charset parameter.
I have always my tables with charset utf8 and collate utf8_unicode_ci.
I have tried with mariadb / mysql and nothing work he never detect my charset configuration.
I have drop my database, recreate and migrate mutiple times and clear cache everytime. But he doesn't work.
commands :
php bin/console doctrine:database:drop --force
php bin/console doctrine:database:create
php bin/console make:migration
php bin/console doctrine:migration:migrate
here my configuration file :
doctrine:
dbal:
driver: pdo_mysql
host: "%env(DATABASE_MASTER_HOST)%"
dbname: "%env(DATABASE_DBNAME)%"
user: "%env(DATABASE_USER)%"
password: "%env(DATABASE_PASSWORD)%"
slaves:
slave1:
host: "%env(DATABASE_SLAVE_HOST)%"
dbname: "%env(DATABASE_DBNAME)%"
user: "%env(DATABASE_USER)%"
password: "%env(DATABASE_PASSWORD)%"
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
dql:
string_functions:
GROUP_CONCAT: DoctrineExtensions\Query\Mysql\GroupConcat
IF: DoctrineExtensions\Query\Mysql\IfElse
FIND_IN_SET: App\DQL\FindInSet
When i add to my sql configuration file :
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
My database is created with utf8mb4_unicode_ci
but my tables is always generate with utf8 / utf8_unicode_ci
It work if i create my entity with the options parameter:
#ORM\Table(options={"charset":"utf8mb4"}...)
But i don't want to change all my table like that and my jointable are always with utf8.
why he don't take my configuration of charset.
It look likes something doens't work when i use MasterSlaveConnection.
Thanks a lot for your help.

Match Against Doctrine Extension configuration

I'm trying to make match against doctrine extension work but i get error with doctrine configuration file. I got Unrecognized option "dql" under "doctrine.orm" . How to propely use symfony 4 + doctrine + match against extension?
Match against file + conf https://gist.github.com/ZeBigDuck/1234419#file-addfulltextindexescommand-php
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
orm:
dql:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# string_functions:
# MATCH_AGAINST: App\Extension\Doctrine\MatchAgainst
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
entity_managers:
default:
dql:
string_functions:
MATCH_AGAINST: App\Extension\Doctrine\MatchAgainst
Try it like this:
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
string_functions:
MATCH_AGAINST: App\Extension\Doctrine\MatchAgainst
EDIT.. It should be something like this (not tested):
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
string_functions:
MATCH_AGAINST: App\Extension\Doctrine\MatchAgainst
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App

errors with the fosuserbundle doctrine schema installation and the run command is empty

I'm trying to install fosuserbudle and I was doing it step by step but with the documentation provided on github, I've that problem and I don't know how to fix it:
LENOVO#LENOVO-G500DC /c/wamp/www/pfe (master)
$ php app/console cache:clear
Fatal error: Class 'Symfony\Component\Console\Input\ArgvInput' not found in C:\w
amp\www\pfe\app\console on line 17
Call Stack:
0.0000 236552 1. {main}() C:\wamp\www\pfe\app\console:0
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
framework:
#esi: ~
translator: ~
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
#FOS UserBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: Acme\UserBundle\Entity\User
You should update your question, but for your error SQLSTATE[HY000][2002] it is related with your database configuration. check if the port number is correct : 3306 and the host in your parameters.yml, and if that doesnt help show us your parameters.yml
Edit:
update your parameters.yml like this :
no brakets needed. and no comma need.
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: symfony
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
database_path: null

Sylius, SearchBundle

Search in latest Sylius-standard does not work:
[Syntax Error] line 0, col 92: Error: Expected known function, got 'MATCH'
[1/2] QueryException: select u.itemId, u.tags, u.entity from Sylius\Bundle\SearchBundle\Model\SearchIndex u WHERE MATCH(u.value) AGAINST (:searchTerm) > 0
How to fix?
You need to add the custom function to you doctrine config as in the Sylius app/config/config.yml
doctrine:
...
orm:
dql:
string_functions:
MATCH: Sylius\Bundle\SearchBundle\Extension\Doctrine\MatchAgainstFunction
Here are the steps to get it working :
In app/config/config.yml put in the following lines
doctrine:
dbal:
driver: %sylius.database.driver%
host: %sylius.database.host%
port: %sylius.database.port%
dbname: %sylius.database.name%
user: %sylius.database.user%
password: %sylius.database.password%
charset: UTF8
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
auto_mapping: true
mappings:
gedmo_loggable:
type: annotation
prefix: Gedmo\Loggable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
is_bundle: false
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
dql:
string_functions:
MATCH: Sylius\Bundle\SearchBundle\Extension\Doctrine\MatchAgainstFunction
In your mysql database look for the table sylius_search_index and check if it has a full index on the value column, if not just run the below command :
ALTER TABLE sylius_search_index ADD FULLTEXT index_name(
value
)
On the console run the following command for your products:
php app/console sylius:search:index
The above command builds a list of search terms for the search in the sylius_search_index table value column.
That should be all !

SQL Server DB Connection with Symfony2 and Doctrine

I'm trying to generate the schema of the database in a SQL Server database, using the following instruction: php app/console doctrine:schema:create.
This is the error message:
Call to undefined function Doctrine\DBAL\Driver\SQLSrv\sqlsrv_connect() in C:\Projects\Project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\SQLSrvConnection.php
PARAMETERS FILE
parameters:
database_driver: pdo_sqlsrv
database_host: localhost
database_port: 1433
database_name: dbname
database_user: user
database_password: password
CONFIG FILE
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
#charset: UTF8
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
I guess you have NOT installed php plugin for that

Resources