"Undefined index: localhost" PHPUnit exception in Codeception with Symfony2 module - symfony

I've got this very simple acceptance test using Codeception and its Symfony2 module:
public function myTest(AcceptanceTester $I)
{
$I->wantTo('test something');
$I->amOnRoute("acme_site_home.es");
$I->dontSee('hello');
}
When I run it I get an Undefined index: localhost PHPUnit_Framework_Exception triggered by a call to $request->server->get("HTTP_HOST") in my route action.
I already tried the following:
Adding this to phpunit.xml:
<phpunit>
<php>
<server name='HTTP_HOST' value='http://some.host.com' />
</php>
</phpunit>
Adding this to my test:
$_SERVER['HOST_NAME'] = "some.host.com";
Adding this to my test:
$_SERVER['HTTP_HOST'] = "some.host.com";
None of this works, I always get the same error message.
How could I fix this?
Notes
[everything given here is sanitized (passwords, hostnames, etc.) and some line breaks and indentation were added for readability]
Just in case, my acceptance suite settings are as follows:
class_name: AcceptanceTester
modules:
enabled:
- Asserts
- Db
- Symfony2
- Doctrine2
- \Tests\Helper\Acceptance
And my Codeception settings:
namespace: Tests
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled: [ Codeception\Extension\RunFailed ]
modules:
config:
Db:
dsn: 'mysql:host=localhost;dbname=acme_test'
user: 'root'
password: 'blahblah'
dump: 'tests/_data/dump.sql'
populate: false
cleanup: false
Doctrine2:
depends: Symfony2
cleanup: false
PhpBrowser:
url: http://acme.com
WebDriver:
browser: firefox
url: http://acme.com
REST:
depends: Symfony2
url: http://acme.com
Here is the result of running the test with the -vvv flag:
$ bin/codecept run tests/acceptance/ExtranetBundle/Controller/DefaultControllerCest.php -vvv
Codeception PHP Testing Framework v2.1.3
Powered by PHPUnit 4.8.13 by Sebastian Bergmann and contributors.
Tests.acceptance Tests (1) ---------------------------------------------------------------------------------------------------------------------------
Modules: Asserts, Db, Symfony2, Doctrine2, \Tests\Helper\Acceptance
------------------------------------------------------------------------------------------------------------------------------------------------------
Test something (Acceptance\ExtranetBundle\Controller\DefaultControllerCest::myTest)
Scenario:
* I am on route "acme_site_home.es"
[Page] http://localhost/es
[User] anon. []
* I don't see "hello"
FAIL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------------------------------------------------------------------------------------------------------------------------------
Time: 4.13 seconds, Memory: 65.75Mb
There was 1 failure:
---------
1) Failed to test something in Tests\Acceptance\ExtranetBundle\Controller\DefaultControllerCest::myTest (tests/acceptance/ExtranetBundle/Controller/DefaultControllerCest.php)
Step I don't see "hello"
Fail Failed asserting that /es
-->
Undefined index: localhost (500 Internal Server Error)
[Content too long to display. See complete response in '_output' directory]
--> does not contain "hello".
Scenario Steps:
2. $I->dontSee("hello") at tests/acceptance/ExtranetBundle/Controller/DefaultControllerCest.php:15
1. $I->amOnRoute("acme_site_home.es") at tests/acceptance/ExtranetBundle/Controller/DefaultControllerCest.php:14
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/Constraint/Not.php:100
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/Assert.php:2255
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Util/Shared/Asserts.php:280
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php:1263
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php:284
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Step.php:193
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Shared/Actor.php:99
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Scenario.php:101
/Volumes/Utilisateurs/marc/Sites/acme.com/tests/_support/_generated/AcceptanceTesterActions.php:831
/Volumes/Utilisateurs/marc/Sites/acme.com/tests/acceptance/ExtranetBundle/Controller/DefaultControllerCest.php:15
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/Di.php:112
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Cest.php:127
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Cest.php:136
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Cest.php:66
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestCase.php:909
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestCase.php:768
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestResult.php:612
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestCase.php:724
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestSuite.php:747
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php:89
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/SuiteManager.php:153
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Codecept.php:203
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Codecept.php:172
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Command/Run.php:184
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:878
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
/Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/codecept:28
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
And here is the error stack trace given by Symfony in the _output directory:
PHPUnit_Framework_Exception: Undefined index: localhost
at n/a
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Subscriber/ErrorHandler.php line 48
at Codeception\Subscriber\ErrorHandler->errorHandler('8', 'Undefined index: localhost', '/Volumes/Utilisateurs/marc/Sites/acme.com/src/Acme/SiteBundle/Controller/DefaultController.php', '160', array(
'request' => object(Request),
'locale' => 'es',
'registrationForm' => object(Form),
'typeAppFb' => array(
'acme.com' => array(
'appId' => '123456789123456',
'secret' => '123456789abcdef123456789abcdef12'
),
'dev.acme.com' => array(
'appId' => '123456789123456',
'secret' => '123456789abcdef123456789abcdef12'
),
'www.prod-acme.com' => array(
'appId' => '123456789123456',
'secret' => '123456789abcdef123456789abcdef12'
)
)
))
in /Volumes/Utilisateurs/marc/Sites/acme.com/src/Acme/SiteBundle/Controller/DefaultController.php line 160
at Acme\SiteBundle\Controller\DefaultController->homeAction(object(Request))
in line
at call_user_func_array(array(object(DefaultController), 'homeAction'), array(object(Request)))
in /Volumes/Utilisateurs/marc/Sites/acme.com/app/bootstrap.php.cache line 3109
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in /Volumes/Utilisateurs/marc/Sites/acme.com/app/bootstrap.php.cache line 3071
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in /Volumes/Utilisateurs/marc/Sites/acme.com/app/bootstrap.php.cache line 3222
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in /Volumes/Utilisateurs/marc/Sites/acme.com/app/bootstrap.php.cache line 2444
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Client.php line 81
at Symfony\Component\HttpKernel\Client->doRequest(object(Request))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/Connector/Symfony2.php line 38
at Codeception\Lib\Connector\Symfony2->doRequest(object(Request))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/BrowserKit/Client.php line 327
at Symfony\Component\BrowserKit\Client->request('GET', '/es', array(), array(), array(), null, true)
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php line 130
at Codeception\Lib\InnerBrowser->clientRequest('GET', '/es', array(), array(), array(), null)
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php line 159
at Codeception\Lib\InnerBrowser->_loadPage('GET', '/es')
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/InnerBrowser.php line 203
at Codeception\Lib\InnerBrowser->amOnPage('/es')
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Module/Symfony2.php line 197
at Codeception\Module\Symfony2->amOnRoute('acme_site_home.es')
in line
at call_user_func_array(array(object(Symfony2), 'amOnRoute'), array('acme_site_home.es'))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Step.php line 193
at Codeception\Step->run(object(ModuleContainer))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Shared/Actor.php line 99
at Codeception\TestCase\Cest->runStep(object(Condition))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Scenario.php line 101
at Codeception\Scenario->runStep(object(Condition))
in /Volumes/Utilisateurs/marc/Sites/acme.com/tests/_support/_generated/AcceptanceTesterActions.php line 579
at Tests\AcceptanceTester->amOnRoute('acme_site_home.es')
in /Volumes/Utilisateurs/marc/Sites/acme.com/tests/acceptance/ExtranetBundle/Controller/DefaultControllerCest.php line 14
at Tests\Acceptance\ExtranetBundle\Controller\DefaultControllerCest->myTest(object(AcceptanceTester))
in line
at ReflectionMethod->invokeArgs(object(DefaultControllerCest), array(object(AcceptanceTester)))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Lib/Di.php line 112
at Codeception\Lib\Di->injectDependencies(object(DefaultControllerCest), 'myTest', array(object(AcceptanceTester), object(Scenario)))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Cest.php line 127
at Codeception\TestCase\Cest->invoke('myTest', array(object(AcceptanceTester), object(Scenario)))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Cest.php line 136
at Codeception\TestCase\Cest->executeTestMethod(object(AcceptanceTester))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/TestCase/Cest.php line 66
at Codeception\TestCase\Cest->testCodecept()
in line
at ReflectionMethod->invokeArgs(object(Cest), array())
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestCase.php line 909
at PHPUnit_Framework_TestCase->runTest()
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestCase.php line 768
at PHPUnit_Framework_TestCase->runBare()
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestResult.php line 612
at PHPUnit_Framework_TestResult->run(object(Cest))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestCase.php line 724
at PHPUnit_Framework_TestCase->run(object(PHPUnit_Framework_TestResult))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/phpunit/phpunit/src/Framework/TestSuite.php line 747
at PHPUnit_Framework_TestSuite->run(object(PHPUnit_Framework_TestResult))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php line 89
at Codeception\PHPUnit\Runner->doEnhancedRun(object(Suite), object(PHPUnit_Framework_TestResult), array(
'silent' => false,
'debug' => false,
'steps' => false,
'html' => false,
'xml' => false,
'json' => false,
'tap' => false,
'report' => false,
'colors' => true,
'coverage' => false,
'coverage-xml' => false,
'coverage-html' => false,
'coverage-text' => false,
'groups' => null,
'excludeGroups' => null,
'filter' => null,
'env' => null,
'fail-fast' => false,
'verbosity' => '4',
'interactive' => true,
'no-rebuild' => false,
'bootstrap' => '_bootstrap.php',
'memory_limit' => '1024M',
'log' => false,
'strict_xml' => false,
'verbose' => true
))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/SuiteManager.php line 153
at Codeception\SuiteManager->run(object(Runner), object(PHPUnit_Framework_TestResult), array(
'silent' => false,
'debug' => false,
'steps' => false,
'html' => false,
'xml' => false,
'json' => false,
'tap' => false,
'report' => false,
'colors' => true,
'coverage' => false,
'coverage-xml' => false,
'coverage-html' => false,
'coverage-text' => false,
'groups' => null,
'excludeGroups' => null,
'filter' => null,
'env' => null,
'fail-fast' => false,
'verbosity' => '4',
'interactive' => true,
'no-rebuild' => false,
'bootstrap' => '_bootstrap.php',
'memory_limit' => '1024M',
'log' => false,
'strict_xml' => false,
'verbose' => true
))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Codecept.php line 203
at Codeception\Codecept->runSuite(array(
'class_name' => 'AcceptanceTester',
'modules' => array(
'enabled' => array(
'Asserts',
'Db',
'Symfony2',
'Doctrine2',
'\Tests\Helper\Acceptance'
),
'config' => array(
'Db' => array(
'dsn' => 'mysql:host=localhost;dbname=acme_test',
'user' => 'root',
'password' => 'blahblah',
'dump' => 'tests/_data/dump.sql',
'populate' => false,
'cleanup' => false
),
'PhpBrowser' => array(
'url' => 'http://acme.com'
),
'WebDriver' => array(
'url' => 'http://acme.com',
'browser' => 'firefox'
),
'REST' => array(
'url' => 'http://acme.com',
'depends' => 'Symfony2'
),
'Doctrine2' => array(
'depends' => 'Symfony2',
'cleanup' => false
)
),
'depends' => array()
),
'colors' => true,
'bootstrap' => '_bootstrap.php',
'memory_limit' => '1024M',
'log' => false,
'strict_xml' => false,
'coverage' => array(),
'namespace' => 'Tests',
'groups' => array('failed' => 'tests/_output/failed'),
'path' => '/Volumes/Utilisateurs/marc/Sites/acme.com/tests/acceptance/',
'shuffle' => false,
'error_level' => 'E_ALL & ~E_STRICT & ~E_DEPRECATED'
),
'acceptance',
'ExtranetBundle/Controller/DefaultControllerCest.php'
)
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Codecept.php line 172
at Codeception\Codecept->run('acceptance', 'ExtranetBundle/Controller/DefaultControllerCest.php')
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/src/Codeception/Command/Run.php line 184
at Codeception\Command\Run->execute(object(ArgvInput), object(ConsoleOutput))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php line 259
at Symfony\Component\Console\Command\Command->run(object(ArgvInput), object(ConsoleOutput))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php line 878
at Symfony\Component\Console\Application->doRunCommand(object(Run), object(ArgvInput), object(ConsoleOutput))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php line 195
at Symfony\Component\Console\Application->doRun(object(ArgvInput), object(ConsoleOutput))
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php line 126
at Symfony\Component\Console\Application->run()
in /Volumes/Utilisateurs/marc/Sites/acme.com/vendor/codeception/codeception/codecept line 28

It was a two-sided issue:
The code doesn't handle unknown domains well and emits a warning, PhpUnit turns the warning into exception.
To test the request to specific domain, you must make request to that domain, e.g. $I->amOnPage('http://acme.com/es');. Since you are using a Symfony2 module, it doesn't make the actual HTTP request to that sites, but handles it internally. If you are using amOnRoute() method, make sure that the url generated by the route includes the hostname component.
P.S. I don't know how does the site bundle work, but I recommend having at least one hostname based route for that domain or your test may stop working with future versions of Codeception.

Related

I have faced a problem to set Global color as default Elementor widget development

I have written this code( Please take a look at below), But it show this error """"
Fatal error: Uncaught Error: Class 'Elementor\Global_Typography' not found in E:\xampp\htdocs\plugin\wp-content\plugins\Test Plugin\widgets\test-widget.php:126 Stack trace: #0 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includes\base\controls-stack.php(1951): ETPWidget->_register_controls() #1 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includes\base\controls-stack.php(488): Elementor\Controls_Stack->init_controls() #2 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includes\base\widget-base.php(148): Elementor\Controls_Stack->get_stack() #3 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includes\base\controls-stack.php(294): Elementor\Widget_Base->get_stack() #4 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includes\base\controls-stack.php(2040): Elementor\Controls_Stack->get_controls() #5 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includes\base\controls-stack.php(1012): Elementor\Controls_Stack->sanitize_settings(Array) #6 E:\xampp\htdocs\plugin\wp-content\plugins\elementor\includ in E:\xampp\htdocs\plugin\wp-content\plugins\Test Plugin\widgets\test-widget.php on line 126
""
$this->add_control(
'title_color',
[
'label' => __( 'Title Color', 'etpaddons' ),
'type' => \Elementor\Controls_Manager::COLOR,
'scheme' => [
'type' => \Elementor\Scheme_Color::get_type(),
'value' => \Elementor\Scheme_Color::COLOR_1,
],
'global' => [
'default' => \Elementor\Global_Color::COLOR_PRIMARY,
],
'selectors' => [
'{{WRAPPER}} .etpaddons-heading' => 'color: {{VALUE}}',
],
]
);
You have to import those namespaces first
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;

SQLITE not working with Codeigniter in Exeoutput4PHP

In my Codeigntier Project under EXEOUTPUT4PHP, I have set databse.php file as below:
$db['default'] = array(
'dsn' => '',
'hostname' => '',
'username' => '',
'password' => '',
'database' => '../dbname.db',
'dbdriver' => 'sqlite3',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
In PHP Settings-> PHP Extensions option of EXEOUTPUT4PHP, I have compiled php_pdo_sqlite.dll and php_sqlite3.dll into exe
In PHP.ini, I have uncommented the lines: extension=php_pdo_sqlite.dll and extension=php_sqlite3.dll
Still on running the application, I am getting the following error:
#### An uncaught Exception was encountered
Type: Error
Message: Class 'SQLite3' not found
Filename: EXELocation\Data\system\database\drivers\sqlite3\sqlite3_driver.php
Line Number: 89
Backtrace:
File: EXELocation\Data\application\models\User_model.php
Line: 6
Function: database
File: EXELocation\Data\application\controllers\User.php
Line: 8
Function: model
File: EXELocation\Data\index.php
Line: 315
Function: require_once

Allow spaces when using Select2 tags symfony

I try to create tags if not exist by using select2 entity. When I try to add a tag that contains spaces I can't.
For example :
"Yupi yola" --> not work because tag contains spaces, is getting only first word "Yupi".
"Test" ---> work
"Test_test" ---> work
I added the Select2Entity in my form type
->add('groupe', Select2EntityType::class, [
'remote_route' => 'route',
'class' => Class::class,
'primary_key' => 'id',
'text_property' => 'name',
'minimum_input_length' => 2,
'page_limit' => 10,
'allow_clear' => true,
'delay' => 250,
'cache' => true,
'cache_timeout' => 60000, // if 'cache' is true
'language' => 'en',
'placeholder' => 'Select a group',
'allow_add' => array(
'enabled' => true,
'new_tag_text' => '',
'tokenSeparators'=> '[",", " "]'
),
'multiple' => false,
'attr' => ['style' => 'width:100%'],
'scroll' => true,
])
Please help me. Thx in advance.
Instead of 'tokenSeparators', use 'tag_separators'
'allow_add' => array(
'enabled' => true,
'new_tag_text' => '',
'new_tag_prefix' => '__',
'tag_separators'=> '[",", " "]'
)

Symfony 3 weird "choice" error

I'm trying to build a checkbox list in Symfony 3.
This code:
$choices = [
'a' => 'fsssssss',
];
$builder->add('memberships', ChoiceType::class, [
'choices' => $choices,
'expanded' => true,
'multiple' => false
]);
Returns the following error: Catchable Fatal Error: Object of class Doctrine\ORM\PersistentCollection could not be converted to string in vendor/symfony/symfony/src/Symfony/Component/Form/ChoiceList/ArrayChoiceList.php (line 73)
If I add two more options, the error goes away and the field is shown correctly:
$choices = [
'a' => 'fsssssss',
'd' => 'fsssssss',
'g' => 'fsssssss',
];
$builder->add('memberships', ChoiceType::class, [
'choices' => $choices,
'expanded' => true,
'multiple' => false
]);
Actually, there are many combinations that work and many that don't; I failed to see any pattern.
Am I doing something wrong? Is there some sort of cache I need to clear?
Just to close this question:
If you use a form with the data_class option and a form field represents a property of an entity which should get selected by choices you can use EntityType:
$builder->add('memberships', EntityType::class, [
'class' => MyClass::class,
'choices' => $choices,
'expanded' => true,
'multiple' => false
]);

Unsupported driver [oracle] in Laravel 5 when using yajra/laravel-oci8

I've seen that this question has been made Unsupported driver in laravel 4 when using laravel-oci8 package but the answere wasn't really usefull since the thread specify on https://github.com/yajra/laravel-oci8/issues/2 was resolved by just installing Oracle instant client and I already have it istalled.
I am trying to integrate oracle DB with laravel 5 app using yajra/laravel-oci8 package, I have folow the installation process and I have verified the specified requirements but with no success. When ever I try to run php artisan route:list or php artisan migrate it tells me that [InvalidArgumentException] Unsupported driver [oracle].
My Config/database.php is the following
...
'default' => 'oracle',
...
'connections' => [
'oracle' => array(
'driver' => 'oracle',
'host' => env('DB_HOST', 'localhost'),
'port' => '1521',
'database' => 'xe',
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'AL32UTF8',
'prefix' => '',
),
...
]
Am I missing any other configuration?
UPDATE
For anybody crossing this question.
The problem back then was that I incorrectly added the service provider (Yajra\Oci8\Oci8ServiceProvider::class,) class in the config/app.php
this is my config:
'oracle' => [
'driver' => 'oracle',
'tns' => "(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = XE) (SID = XE)))",
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1521'),
'database' => env('DB_DATABASE', 'XE'),
'username' => env('DB_USERNAME', 'XEUSER'),
'password' => env('DB_PASSWORD', 'XEPASSWD'),
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
],
change your config :
'oracle' => [
'driver' => 'oci8',
'host' => 'localhost',
'port' => '1521',
'database' => 'oracle_ID',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'prefix' => '',
'prefix_schema' => '',
],
to check : take on your controller function
$data = DB::connection('oracle')->table('your_table')->take(1)->get();
var_dump($data);
it works for me

Resources