I have a symfony 1.4 project that has been is use for several years now. In the past few weeks the autoload has started skipping classes, arbitrarily as far as I can tell. This occurs in both plugins and files located in the lib/ directory.
If I rename the class the problem is solved. I've searched and there are no other classes of the same name in the entire project. There are also no errors in the classes. Many of these classes have not been edited in 2 years so literally nothing is changing in the classes.
When I clear the cache, some class is ignored on the next page load. classes in files in the same directory are picked up no problem.
Anyway, trying desperately to figure out what is going on. I can't find an error in symfony's error logs nor in apache or any other server log. But, I'm sure there is some logical reason why this is happening.
Also, just noticed, the autoload works on normal pages, it's only pages delivered over SSL that break.
Maybe a bit late, but i had the same problem and i add to convert the end of line from unix to windows
Related
I am using these two libraries from composer
"require": {
"alterfw/php-form-generator": "^0.1.2",
"rlanvin/php-form": "dev-master"
},
Biggest issue is both has the same class name Form with no namespace defined. Now no matter either I am instantiating only one class or both on the same page it is giving me an error as below
Fatal error: Call to undefined method Form::create() in...
create method is to generate form markup from alterfw/php-form-generator library.
So when I tried this
$form = Form::create('path-to-action.php');
$form->add(Form::text('settings')->setLabel('Settings')->setValue('None'));
echo $form->render();
Giving me the error mentioned above. For me it is difficult to understand why even I hven't instantiate another class it is still giving error.
I a also not so much familiar with composer to dig into myself without any guide.
So is there any way so I can use both libraries at the same time?
Tip: Packages without a vendor namespace are a bad practice, as you can see here. I recommend creating an issue for both packages saying they should really add a vendor namespace.
The problem here is that as soon as you use Form in your code, the class isn't already loaded and Composer's autoloader is executed. As it has 2 packages to load the class from, it'll pick the first registered autoload rule. This results in the wrong Form class: Problem!
You can swap the packages position in your composer.json, but this means the other class is no longer usable.
Another solution is to require the class yourself by using the require()/require_once() PHP functions. This is a bad practice and also means you can only use one of the 2 Form classes (requiring the other form class after one is already required results in a "Class with name "Form" already exists" PHP error).
TL;DR: You can only use one of the 2 packages in the same application.
There is really no shortage of form validation libraries. Every single framework should have one component for this.
So I'd recommend selecting your libraries carefully.
We have here the first library "alterfw/php-form-generator", which is 4 years old, being unmaintained since then, until it got forked 4 months ago with adding composer.json. Four years ago, PHP 5.2 was still common, so it is no real surprise that this code has no namespace. It also has no real documentation, because the link in the readme file is dead. The forked repository of this library does not allow creating issues. :( I doubt that the upstream repository will care about anything after 4 years of not maintaining it.
The second library "rlanvin/php-form" seems to be tied to non-public code. You opened a ticket to add namespace to that one class, and effectively got rejected (saying that the maintainer will not add namespaces because it is more convenient for him, but you could edit the file yourself to add it simply does not cut it). Packagist shows that this library has 31 installs. It's not completely right to say that "nobody uses this code", but it is very close.
If your task is form validation and form generation, I'd say that either the Symfony or Zend components will likely perform that task very well. There probably is no need to resort to libraries that "nobody" uses, and that do not apply modern development methods like namespaces (available since PHP 5.3, which was released in 2009).
HELP PLEASE! When upgrading my Joomla 2.5.24 to 3.3, the process hung. Now I get the WSOD and get into the administrator (front end does not work either) with error:
ADMINISTRATOR:
Fatal error: Call to undefined method JAdministrator::setHeader() in /home/.... /libraries/cms/html/behavior.php on line 712
FRONTEND:
Fatal error: Call to undefined method JHtml::getJSObject() in /home/..... /libraries/cms/html/behavior.php on line 271
I did a backup up all databases and the files prior to update, but the problem is not resolved when restoring either. I have spent all day trying to figure this out, and I don't know how to debug the setheader(). Can anyone please help me?
First of all, get you site back up.
Since you have a backup, that's going to be "easy".
a. Download a copy of Joomla 3.3, extract the files, and run
find
to get the list of files in Joomla 3.3.
b. Now delete all of those files from your current installation, and restore the backup on top.
There are files that Joomla 3.3 adds that will break Joomla 2.5.
c. Restore the database, and your old site will be working again.
Now the tough part. Figure out what's wrong.
Make an off-line copy of your website.
Are you in the "I'm feeling lucky" mood? Run the update and follow the instructions below.
Do you want to minimize the headaches or you're not comfortable with typing shell commands? First update all your third party extensions to their latest version, and make sure they support Joomla 3.3.
You must have some third party extension that's breaking the site. Here's my quick and dirty procedure to identifying the culprit (but don't share it, it's a secret):
Is it a module, a plugin or a component?
If the WSOD is on both the frontend and backend, it should be a plugin.
Is it a plugin? Rename the plugins folder "plugins2". If the site loads, rename it back to plugins, cd to it, and rename in turn system, content etc. until you find where it is. Keep digging down to the last level and isolate the plugin.
Is it a module? Rename the modules folder and see if the site loads. If it does, go back and rename the folders of the modules you are using in turn. In case you don't know which ones you're using, move them away a few at a time using wildcards to be quicker
Is it a component? Then it's the homepage component and the other pages should load fine.
Once you have identified the culprit, download an update, and apply it manually (open the zip and copy the files where they belong).
You might have to do this multiple times for each broken extension. Remember Murphy's law.
I'm having a problem with FuelPHP failing to autoload classes. On my staging server (Ubuntu, PHP 5.3.10) it is unable to find custom classes in the fuel/app/classes directory, and it also can't run oil test (I get the error message sh: 1: phpunit: not found). Oddly, it works fine on my local development version (Windows, PHP 5.3.6).
I suspected it might have something to do with Composer, which I'm using for the first time on this project, but the problem is not fixed when I comment out the line require APPPATH.'vendor/autoload.php'; from bootstrap.php (the app still fails to load custom classes from fuel/app/classes)
I'm stumped: I've used FuelPHP on lots of projects and have never had any problems with the Autoloader. What's particularly puzzling is that the same code seems to work fine in one place and not in another. I'd be very grateful for any suggestions about how to fix this.
I realize this question was asked a long time ago, but I had the same problem, so for the benefit of anyone else with this problem, here is what worked for me:
create a new php file called oil.php in the app/config directory with the following code:
<?php
// Unit tests will get shell error 'phpunit: command not found' unless
// the path to php unit is specified.
return array (
'phpunit' => array (
'binary_path' => 'fuel/vendor/bin/phpunit',
),
);
I am using fuel 1.7.2. More information can be found here.
Although the above code fixed the specific PHPunit problems, I still had issues with Fuel and autoloaders not working. Fuel PHP does not follow psr-4 (many of the core fuel files have multiple class definitions in the same file), which can cause problems with certain autoloaders.
I'm using the ModX CMS.
And this error, document.mutate.save is undefined keeps coming up if I were to save a chunk.
Assuming it was a faulty install, I deleted the application, and reinstalled it four times. Those included:
Twice from the original working application on my testing remote server.
From the latest version of Evolution on ModX's website
From another working site I maintain that was also created in ModX.
Assuming it was a javascript conflict, I went into my QM, and removed jQuery from the backend, and then eventually removed jQuery all together unsure if it was still being placed in there. I can not view the source of the backend because it is entirely composed out of iFrames.
The document.mutate.save files come from a folder located in: /manager/actions/
This folder is set to 777 as well as all the surrounding golders and the parent manager folder as well.
Anyone have any idea as to why this error is being called, and how to fix it?
I'm a rails guy, but this seems like a simple method not being defined in the controller problem. Unfortunately, I'm not too conscious of PHP's MVC architecture otherwise, I would fix this manually.
Thanks!
Old thread, I know... but I have a possible solution which worked for me.
After a lot of fiddling around, I finally found that I had activated the editor in the configurations, but had uninstalled the TinyMCE Plugin. After deactivating the editor, the error disappeared.
I run multiple websites all running off of a single installation of CodeIgniter on my server (separate application directories and a single system directory). This has been working fabulously and I don't see any reason to change it at this point.
I find myself writing library classes to extend/override CI all of the time and many times if I find a bug or improve effeciency I have to go back to several websites to make the same adjustments at risk of a typo that breaks one of the websites. Because of this it requires that I change each file and then test that site for bugs.
I have been pondering a solution of using a single libraries directory in a central location and symlinking all of my websites to that central directory. Then when I make a file change it will immediately propagate to all of the downstream websites. It will still require that I test each one for errors, but I won't have to make the changes multiple times. Anything that is specific to a single website will either be a non-shared file (still in the linked directory just not used elsewhere) or can be put in a local helper.
Also, I keep separate 'system' directories by CI version so I can migrate my websites independently if necessary--this central libraries file would be attached to a specific version to reduce possible breaks.
Does anyone see potential issues or pitfalls from taking this approach? Has anyone accomplished this in another direction that I should consider?
Thanks in advance!
I think this actually makes sense :] Go for it. Even on official CodeIgniter page, they mention it's possible.
Also, I don't see one reason why there should be any problem.
Edit: they touch the problem of multiple sites here: http://codeigniter.com/user_guide/general/managing_apps.html
also:
http://codeigniter.com/wiki/Multiple_Applications/
http://www.exclusivetutorials.com/setting-multiple-websites-in-codeigniter-installation/
How to Handle Multiple Projects in CodeIgniter?
http://codeigniter.com/forums/viewthread/56436/
I have a single system directory and separate application directories for my CI apps. In order to share libraries and some view templates between my apps, I have created a "Common" directory, in the same folder as the CI system and with the same structure as a regular app folder and used symlinks, but you can modify the Loader class so that it looks in the Common folder too. My setup looks something like this:
/var/CodeIgniter/
/var/Common/
/var/Common/config/
/var/Common/controllers/
...
/var/Common/libraries/
...
/var/www/someapp/
/var/www/someotherapp/
...
I'm not sure how you handle publishing your sites (assuming you actually do any of that), but I'd look into version control. For example, in SVN you can make external to another svn directory (or file) and then just update the current svn directory which grabs the external file. This approach gains one benefit from the others, which is when you modify the common library, the others aren't immediately affected. This prevents unwanted breaks before you have time to go test all the sites using the common library. You can then just update each site's folder whenever you are ready to test the changes. This is "more work", but it prevents code duplication AND unwanted breaks.
I wrote a MY_Loader to do exactly that.
http://ellislab.com/forums/viewthread/136321/