Symfony2 Re-organization config files : parameters.dist.yml issue - symfony

I've followed document to re organize files in app/config directory.
Now I have config/common (with config, parameters, parameters.dist, routing, security & services files), and files for each environment in specific directories : app/config/dev and app/config/prod.
But now, when I try to send "composer -n install" to update autoload, I have this error :
[InvalidArgumentException]
The dist file "app/config/parameters.yml.dist" does not exist.
Check your dist-file config or create it.
I know this is a configuration problem, Symfony search my dist file in app/config, how can I redirect it to app/config/common ?
I don't know where is the "dist-file config" written in error.
Thanks!

Found !
It is in composer.json:
under "extra", "incenteev-parameters", I've changed value of "file".

Related

How to handle the "wildcard" * asterisk on a Windows Command

Using
Windows
Local by Flywheel
Composer (task runner)
Working on a Child Theme to a Custom Made "Core" theme.
I'm running composer install on the root of my WP directory to install dependencies on a parent and child theme.
Problem is when the installations are running it errors out when it gets to the src/*.js. I asked the team that set up the page and they told me that it was a problem with how Windows handles wildcard characters, which I understand it as the asterisk* and that they solved it in the pass by getting their employee a Mac. Since these dependencies are not going through, there's files that aren't loading on the website.
Getting a Mac, to solve this issue, is not on the table, so I'm looking to figure out what other options do I have to run this command successfully on a windows?
I tried going directly to the src/ folder and running npx wp-scripts start src on each .js file individually, and it gave a "successful build" message each time, but that didn't fix the issues on the page.
> wp-scripts build src/*.js
assets by status 95 bytes [cached] 2 assets
Entrypoint * = *.js *.asset.php
ERROR in *
Module not found: Error: Can't resolve './src/*.js' in 'C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName'
resolve './src/*.js' in 'C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName'
using description file: C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\package.json (relative path: ./src/*.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js.wasm doesn't exist
as directory
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js doesn't exist
webpack 5.64.1 compiled with 1 error in 149 ms
Script cd wp-content/themes/parentThemeName && npm install && npm run build && composer install --no-interaction --ansi --ignore-platform-reqs handling the install-core-deps event returned with error code 1
Script composer install-core-deps && composer install-child-deps handling the post-install-cmd event returned with error code 1
Thanks for any and all help.
Cheers!

Symfony looks for app folder in wrong place

My Symfony 3.3 application is looking for app folder in wrong place.
I deployed Symfony 3.3 project to a subdomain (subdomain.domain.com). Subdomain folder location on server is: /home/USERNAME/public_html/PROJECTNAME
Subdomain document root is: /home/USERNAME/public_html/PROJECTNAME/web
This is normal Symfony folder structure, nothing changed. Why it doesn't look for app folder in correct place? What am I missing?
Error I get is:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLocatorFileNotFoundException: "The file "/home/USERNAME/public_html/app/config/routing.yml" does not exist." at /home/USERNAME/public_html/PROJECTNAME/var/cache/prod/classes.php line 3040 {"exception":"[object] (Symfony\\Component\\Config\\Exception\\FileLocatorFileNotFoundException(code: 0): The file \"/home/USERNAME/public_html/app/config/routing.yml\" does not exist. at /home/USERNAME/public_html/PROJECTNAME/var/cache/prod/classes.php:3040)"} []
EDIT:
I found out that composer.json was not in the correct folder. I posted that as an answer and accepted it.
composer.json file needs to be in the root folder of the app.
The error message gives you the clue, I don't know how you browse your site, but Symfony tries to find the file from your root folder, I guess you are trying to browse as a domain.if it is subdomain then URL should be like this SubDomainFolderName.DomainName
Or try to solve this using .htaccess
You should run bin/console cache:clear command after deploy.
And what about the content of getCacheDir method in AppKernel?
Should be:
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();

Issue with custome moduel installation in Sulu Admin

I have integrated the Example module in my Sulu-standard installation. The code I used for the example module is from following repository :
https://github.com/sulu/ExampleNewsBundle
And the steps I followed for integration are from this
http://blog.sulu.io/how-to-develop-a-bundle-in-the-sulu-admin-1
After the installation I am getting this error while loading the JS for the module :
"NetworkError: 404 Not Found - http://beauty_dev.com/en/bundles/examplenews/js/main.js?v=develop"
Error: Script error for: /bundles/examplenews/js/main.js http://requirejs.org/docs/errors.html#scripterror
var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
Error: Script error for: /bundles/examplenews/js/main.js http://requirejs.org/docs/errors.html#scripterror
var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
After some research I found that 404 error was due to locale(en) appended in the URL.
Is it possible to remove the locale from the URL?
Any reference will be appreciated.
After adding a new bundle you have to reinstall the assets using the following command:
app/console assets:install --symlink
Symfony doesn't do that automatically, so you have to execute this line, in order for the files to be copied to the web directory. You could also check if the accessed file is available in the web directory, which should be the case after executing the above command.
Regarding the language: You see that because Sulu tries to redirect to the default language if the current URL leads to a 404 and doesn't contain a language.
Are you sure that the files in the web/bundles/examplenews folder exists and you can access from the browser? When the files exists and the webserver returns them correctly the /de will not be prepended.

Creating a Bundle outside src/

I have created a bundle with symfony 2.3 but in this case (cause my teacher asked to me) outside src/ folder so I have ../symfony/fuentes/NameBundle instead of ../symfony/src/NameBundle. The new line appears in AppKernel and my new bundle appears on routing.yml, but when I try to launch the server
Bundle generation
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]?
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: OK
The command was not able to configure everything automatically.
You must do the following changes manually.
- Edit the composer.json file and register the bundle
namespace in the "autoload" section:
I have edit autoload and tried a lot of things (looking for here) but it appears the same error always.
C:\Users\Akenateb\Documents\UOC\AULAMENTOR\Symfony>php app/console server:run 127.0.0.1:8080
PHP Fatal error: Class 'AulaMentor\ExdosBundle\AulaMentorExdosBundle' not found in C:\Users\Akenateb\Documents\UOC\AULAMENTOR\Symfony\app\AppKernel.php on line 20
Can someone help me? I'm really stuck with it.
Thanks in advance.
First of all I want to thanks to the people who has answered. Here is what we have to do if we want to create a bundle outside 'src' folder, for example in 'fuentes' > '..Symfony/fuentes'.
If you have create with 'generate:bundle' I suggest you accept when the generator ask you if you want to create the complete structure, if you have create a bundle with generator goto step 3.
1- Make sure you have registered bundle in AppKernel and It exists there a line like this:
new YourProject\NameprojectBundle\YourProjectNameprojectBundle(),
2- Make sure you have adding a route to your app/config/routing and 'routing.yml' has you new bundle route, like this (you can add a prefix to your url, in this case fuentes):
your_project_name:
resource: "#YourProjectNameprojectBundle/Resources/config/routing.yml"
prefix: /fuentes
3- We edit 'app/autoload.php' and we add this line:
$loader->add('YourProject',realpath(__DIR__.'/../fuentes'));
Finally we can update assets doing with command line:
php app/console assets:install web
Hope it helps to someone.
Best Regards.
Do exactly as said in the comment:
Edit the composer.json file and register the bundle namespace in the "autoload" section
The src folder is automatically loaded using PSR convention. If you set classes outside of the src folder, they have to be declared as well.
In your composer.json file you can add another element in the autoload section. Here's an example that I think will work for your use case:
"autoload": {
"psr-0": {
"NameBundle\\": "fuentes/",
"": "src/"
}
},
Here's how to add simply another bundle outside your Symfony project, when we don't want to mess up with composer.json file.
The 2 first points are the same as in the Michael J.'s answer. Now to the 3rd point:
Say, we need to add a OurCompany/SomeBundle residing in the other project, which relative path is ../../OtherProject/src/OurCompany/SomeBundle to CurrentProject/app dir.
So we add this bundle to the CurrentProject application this way:
$loader->add('OurCompany\\SomeBundle', realpath(__DIR__.'/../../OtherProject/src'));
PLEASE NOTICE how the slashes and backslashes should be used (the remaining / or \ at the end doesn't matter, it's smart enough to figure it out).
And for the whole namespace to be loaded (all bundles namespaces in the other project available in CurrentProject):
$loader->add('OurCompany', realpath(__DIR__.'/../../OtherProject/src'));

Symfony 2 pdo exception

I'm using Symfony 2 and have this row in my parameters.ini:
database_driver = pdo_pgsql
When I was creating database structure with Doctrine everything was good. But if I want to add some doctrine object to my darabase (insert row), I catch an exception:
What I have to do with this?
Are you sure you're using pdo_pgsql? Are you running on localhost? It might be very certain that you are using pdo_mysql driver instead.
However you have to check the following:
php.ini
extension=pdo.so
extension=pdo_mysql.so
or in your case
extension=pdo.so
extension=pdo_pgsql.so
You can check the phpinfo(); to find out the configured database driver.
In your symfony project you have to check the parameters.ini file in config folder. E.g.
[parameters]
database_driver="pdo_mysql"
database_host="localhost"
Besides try to avoid this error
'stty' is not recognized as an internal or external command,
operable program or batch file.
https://github.com/symfony/symfony/issues/4974
First of all, verify your php.ini file: the extensions php_pdo_pgsql and php_pdo must be enabled. Make sure you apply this changes on php.ini file that your symfony project is using, check this on localhost/path_to_your_project/web/config.php. You know if this extensions are enabled executing the function phpinfo().
This command is also helpfull: php -m. It lists on console all the php modules that are loaded.
Tip: check out you Apache error log, there could be something wrong with the load of your extensions. This file is located according to your server configuration.

Resources