Checking that the bundle is autoloaded: FAILED - symfony

I cannot create a bundle. I'm getting "Checking that the bundle is autoloaded: FAILED" which never used to happen before until now. Steps below always worked until today.
Any solutions?
To setup Symfony2:
I downloaded: Symfony_Standard_Vendors_2.4.5.zip
I unzipped under: /var/www/html/local/three. three is the main folder.
I set the permissions:
desktop#ubuntu:/var/www/html/local/three$ sudo chown desktop -R app/logs
desktop#ubuntu:/var/www/html/local/three$ sudo chown desktop -R app/cache
desktop#ubuntu:/var/www/html/local/three$ sudo chmod 777 -R app/cache
desktop#ubuntu:/var/www/html/local/three$ sudo chmod 777 -R app/logs
This URL works fine: http://localhost/local/three/web/app_dev.php
To create my bundle:
desktop#ubuntu:/var/www/html/local/three$ php app/console generate:bundle --namespace=Myblog/PublicBundle
Welcome to the Symfony2 bundle generator
In your code, a bundle is often referenced by its name. It can be the
concatenation of all namespace parts but it's really up to you to come
up with a unique name (a good practice is to start with the vendor name).
Based on the namespace, we suggest MyblogPublicBundle.
Bundle name [MyblogPublicBundle]:
The bundle can be generated anywhere. The suggested default directory uses
the standard conventions.
Target directory [/var/www/html/local/three/app/cache/dev/../src]:
Determine the format to use for the generated configuration.
Configuration format (yml, xml, php, or annotation): yml
To help you get started faster, the command can generate some
code snippets for you.
Do you want to generate the whole directory structure [no]? yes
Summary before generation
You are going to generate a "Myblog\PublicBundle\MyblogPublicBundle" bundle
in "/var/www/html/local/three/app/cache/dev/../src/" using the "yml" format.
Do you confirm generation [yes]? yes
Bundle generation
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? 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:

Solved:
Problem is to do with line:
Target directory [/var/www/html/local/three/app/cache/dev/../src]:
I don't understand why it is suggesting cache path. Old days it was always automatically suggesting src directory instead. I've checked my logs that's why I know. Anyway change it to:
/var/www/html/local/three/src
Done!

This is a known issue now, I guess it will be fixed on the next version
https://github.com/symfony/symfony/issues/10972
https://github.com/symfony/symfony/pull/10999
https://github.com/symfony/symfony-standard/issues/659
for now when the generate:bundle displays this:
The bundle can be generated anywhere. The suggested default directory
uses the standard conventions.
Target directory:
-- /type/your/directory/src here

Related

WordPress file permissions on CentOS7 requiring sudo

I'm running WordPress on my VPS with CentOS 7 LAMP stack.I've followed this guide to set permissions, i.e. I've run
sudo chown apache:apache -R *
to ensure that my wordpress directory is owned by apache:apache.
I've also set WordPress directory and file permissions with these commands:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
(I had to prefix the above commands with sudo)
Normally I manage the server by logging in through SSH using myuser, where myuser belongs to the apache group and the wheel group.
I have 3 problems:
Any file CRUD command in the WordPress directory still requires me to prefix the command with sudo, or else I get a permission error. Since myuser belongs to apache and apache owns the directory, I'm confused as to why I still need to prefix the commands with sudo.
Similar to problem 1, any git command such as a git pull requires me to prefix the command with sudo or else I get a permission error.
When I try to automatically update theme files from my WordPress dashboard web interface, I get permission errors. Interestingly, I'm able to install/update plugins via the WordPress dashboard without any permissions errors.
Any ideas on what I'm missing?
Look at:What does mode_t 0644 mean?
644 means:
* (owning) User: read & write
* Group: read
* Other: read
CRUD is a write command, so you're not allowed to do that. Either you change to 664 or keep using sudo. Basically any writing procedure on the file system would not be allowed without sudo since your user is not the owner (event though he is in the group).
#fortuneRice, CentOS7 features selinux enabled by default, which is often the cause of many hard-to-understand file permission errors.
I would suggest the following:
Edit /etc/sysconfig/selinux
Change SELINUX=permissive (or whatever SELINUX is currently set to in the file) to SELINUX=disabled
Reboot your server (not just the apache web server, but the whole machine)
Disabling SELINUX completely is not a good idea, therefore if this procedure works, you should re-enable SELINUX and fix its configuration.
Configuring SELINUX can be a difficult task, so I suggest you read up on google how to do that :)
chown -R -f user:apache /path of the directory
I also faced that issue and solved this problem by changing the PHP handler.
it is important to use PHP Handler that will run as the file owner.
After I installed HTTP2 and another few features on the way, I changed the PHP handler.
I am running WHM/CPanel on my VPS, and I fixed my issue following these steps:
Under WHM > Software > EasyApache 4 > Customize
Look for the: mod_suphp under the Apache Modules tab and make sure it is enabled, and if you just turned it on to install, follow step two.
Go to the Review tab and click the Provision button to save.
Under Whm > Software > MultiPHP Manager look for PHP Handlers tab.
Choose suphp as the handler for the current PHP version.
That's it. It was the PHP handler.
Edit: I notice that suphp had a conflict with one of my user uploads directories that I am adding dynamically to images a watermark. It seems the suphp handler had permission to upload but doesn't show the pictures.
I also tried the lsapi for the PHP Handler, and it seems to work correctly with the file's permissions and attaching via the .htaccess file watermarks for images.

Symfony2 : clear cache don't generate required file EntityManager_XXXX.php (for doctrine)

After a cache:clear I have this in php log :
PHP Warning: require_once(/var/www/mysite/releases/20150706130613/app/cache/prod/jms_diextra/doctrine/EntityManager_56274d8036816.php): failed to open stream: No such file or directory in /var/www/mysite/releases/20150706130613/app/cache/prod/appProdProjectContainer.php on line 279
I check the file list in app/cache/prod/jms_diextra/doctrine/, I find EntityManager_XXXX.php where XXXX.php is allways different from 56274d8036816 !! So i duplicate the existing file with the required file name and then it works !! The strange thing is it' allways the same file name (56274d8036816) symfony need and never find/generate !!
I don't want to manually create the needed file each time I clear the cache :( what's going wrong ??
Maybe you should add permissions to cache directory
chmod 777 -R cache
Had the same issue.
The other comments are correct, here are the steps:
Delete all files/directories in your cache directory.
chmod -R 777 cache
php app/console cache:warmup
This should succesfully generate the cache.

Symfony2 "Assetic:dump -env-prod" Permission denied Exception

Before i executed an update (composer.phare update) with the root user, every thing works fine, but now when i tries to run "Assetic:dump -env-prod" i get a "Permission denied" error
[Assetic\Exception\FilterException]
An error occurred while running:
'' '-jar' '/home/symfony/www/app/Resources/java/yuicompressor.jar' '--ch
arset' 'UTF-8' '-o' '/tmp/YUI-OUT-vbRlyu' '--type' 'css' '/tmp/YUI-IN-OoRVH
Q'
Error Output:
sh: 1: : Permission denied
Input:
meta.foundation-version{ ...
I tried all the solutions in this post Fontawesome fonts fail after assets:install and assetic:dump
clear the cache, chown, chgrp and chmod nothing worked always the same problem
One way to deal with file permissions when you are running a web based application which requires either auto deployment or constant manual updates like using bin/console from symfony2, its to make sure that the files belongs to the user under which your application runs.
As you did not provide environment settings, I will be making a few assumptions and provide you with a generic setup scenario, hopefully this will help guide you to the the best solution for your specific case.
Environment Assumptions:
OS: linux flavor;
Web server: nginx will be running as www-data;
PHP: php-fpm will running as testapp and using a socket connection for this application;
Generic set-up steps:
In the /etc/nginx/nginx.conf file, make sure that the user/group are set to www-data;
In the /etc/php5/fpm/pool.d/apptest.conf file, make sure that the user & group are set to testapp;
TIP: The file above might need to be created, if that's the case you should just copy the content of the www.conf file located in the same folder.
In the /etc/php5/fpm/pool.d/apptest.conf file, make sure listen.owner & listen.group are set to www-data;
Make sure that you have a line like the one below in this file /etc/php5/fpm/pool.d/apptest.conf:
listen = /var/run/php5-fpm.apptest.sock.
NOTE: the fpm.apptest.sock portion of that line above, its the name of a file that does not exist yet but will be created when you restart php. The benefit is that you will have an isolated php process for this application;
a) In the case on nginx and if you are using socket connections, make sure to add this line in your apptest conf file:
unix:/var/run/php5-fpm.apptest.sock;
b) If you are using apache add this line in that conf file:
-socket /var/run/php5-fpm.apptest.sock;
If you are on a linux box, create user with no password and it should be called, apptest.
Note: apptest is the name of your application, it will also be the user under which php will be running and it should also be the application files/folders owner.
Restart php and nginx/apache.
Tip: to change to a user in linux which has no password, you should have root privileges and run:
sudo -u apptest -i.
After this, you should perform all your commands as the apptest user previously created, including running the symfony2 bin/console.
These are very generic steps, so if you need any clarification, let me know.
I do not recommend to use root for updating. In my opinion the way to go is to have /app/logs /app/cache writable for the server and the src and vendor folder only readable for the server.
So lets say your user and group is: coolman, than try this:
# everything is yours
chown coolman:coolman -R .
# all and group can access folders and read files, you as user can additionally write them
chmod ag=rX,u=rwX -R .
# full access to logs and cache for everyone (also the server)
chmod a+rwX -R app/logs app/cache
You make your composer update with your coolman user.
There is only one small problem, too. The logs might be www-data:www-data rw-r--r-- so you cannot delete them. So just add a line to your app.php and your app/console file:
\umask(0000);
I think this line is commented out as default. This says, that if no explicit rights are set within PHP, than every file which is created will get 0777 - mask = 0777 so you can delete logs and cache then.

PHPUnit Never uses the correct include_path

I've recently installed PHPUnit on a Mac (10.8.3) (running PHP 5.4.7). When I attempt to a run a test phpunit testfile.php for example, I receive:
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or
directory in /Users/myusername/pear/share/pear/PHPUnit/Autoload.php on line 64
Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php'
(include_path='.:') in /Users/myusername/pear/share/pear/PHPUnit/Autoload.php on line 64
The file, /Users/myusername/pear/share/pear/File/Iterator/Autoload.php exists.
php.ini correctly lists the pear directories in the include path:
.:/php/includes:/usr/local/apache/lib/php:/Users/myusername/pear/share/pear/
Yet when I var_dump(get_include_path()); inside of the PHPUnit/Autoload.php file, it prints .: as if it's empty.
Dumping the value of php_ini_loaded_file instead, simply returns false.
Using php -i |grep php\.ini and php --ini only show one php.ini being used/loaded:
Configuration File (php.ini) Path => /usr/local/apache/lib
Loaded Configuration File => /usr/local/apache/lib/php.ini
I repeated the var_dumps of the include_path and the loaded_ini_file from a simple test.php file I ran from the command line and they print out the correct info. So something involved with phpunit is not loading the right/any php.ini.
I'm not using any configurations that are different than default - phpunit was just installed on this machine today.
Make sure the php.ini file you are using is the one loaded for cli php. At least on my install of PHP on Linux, I have two php.ini files, one at /etc/php/cgi-php5.4/php.ini, and the other at /etc/php/cli-php5.4/php.ini. If you change the cgi version, it won't by default affect the cli version, and would cause the include path to be empty.
Another place to check is the phpunit.xml file. It has a section to specify the include path. See here for options available. I'm not sure why phpunit would reset the path but this might be a way to solve the issue.
The solution was:
After running
`pear config-get php_bin` -i | grep -E Configuration\ File\|include_path
It showed that Pear was using a different ini path than php-cli was:
Configuration File (php.ini) Path => /etc
Loaded Configuration File => (none)
include_path => .: => .:
Turns out, Pear had been configured by the original/default Mac OS copy of PHP, not by the custom version I had installed later on.
A quick fix that may not be best long-term was to symlink the ini file it was trying to find:
sudo ln -s /usr/local/apache/lib/php.ini /etc/php.ini
Afterwards, phpunit FakeTest commands are work, and the tests run.
Eventually I need to re-install/re-configure Pear to work with the version of php I've loaded.

Symfony2: How to update a bundle whose source files have been modified?

I am using the KNP Pagination Bundle. I customized the twig file in the bundle source. Then I found a better way of doing it without touching the bundle's files.
Unfortunately, now everytime that I do
bin/vendors install
I get the following error:-
"KNP Paginator Bundle" has local modifications. Please revert or commit/push before running this command again.
My .gitignore file has ignored /vendors
And my deps file has the bundle included too.
Is there a way to uninstall a bundle? So that I can reinstall it?
Or what is the best way to solve my problem?
./bin/vendors doesn't care about content of .gitignore. You can fork desired bundle, do your changes there and change deps file to point to your fork instead.
If you still want to use original bundle and just reinstall it, you can either run ./bin/vendors install --reinstall or just delete the bundle folder from vendor directory and run ./bin/vendors install again.
How about using git --reset? The vendors are fetched using git clone after all.
Can you explain what "git reset" does in plain english?

Resources