performance - How can I transform my YAML file in a PHP one? -


i'm using symfony 2.3.x implement project. involves having 2 huge lists of key -> value pairs in 2 configuration files.

currently, these implemented yaml files , this:

parameters:     values:         part1:             key1: value1             key2: value2             key3: value3             key4: value4             key5: value5             key6: value6         part2:             key1: value1             key2: value2             key3: value3             key4: value4             key5: value5             key6: value6 

and

map:     key1: ['value']     key2: ['value1', 'value2']     key3: ['value1', 'value2', 'value3']     key4: ['value']     key5: ['value1', 'value2', 'value3']     key6: ['value'] 

(the values in first 1 passed class's constructor, that's why it's value under parameters root node)

in symfony\component\httpkernel\dependencyinjection\extension implementation loaded (fairly standard):

$loader = new loader\yamlfileloader($container, new filelocator(__dir__.'/folder')); $loader->load('myfile.yml'); $loader->load('myfile2.yml'); 

everything works fine, these files huge (a few thousand lines each) , it's causing performance issues. i'm not stuck using yaml, thought performance gain skip yaml parsing part entirely , have these values php arrays directly. save me precious milliseconds.

the problem don't know how transform them in php files. how should php arrays ? how symfony read file , gain access arrays ?

i searched symfony's documentation, of writing things in yaml format. find this:

parameters:     key: value 

can written as:

$container->setparameter('key', 'value'); 

but there issues here:

  • there no specification $container comes from
  • when have few thousand parameters, seems slower call setparameter thousands of times
  • if have array in array in array in array, how make function call ?

how can transform yaml files php files ?

thank in advance :) .

parsing files doesn't gain time imo. when don't change container in dev environment, cached normal , won't have problems.

also, if have few thousands lines of parameters, might doing wrong. parameters thing want? think using database them might lot better.


if want way:

there no specification $container comes from

this isn't have worry about. comes php file loader. don't have include definition in file.

when have few thousand parameters, seems slower call setparameter thousands of times

i think so.

if have array in array in array in array, how make function call ?

just use assocative array argument setparameter().


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -