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.
Related
I am new to PHP and Laravel.
I am quite confused about debugging such application. I've set up idea IDE and xdebug, installed Laravel plugin, run apache server, etc.
Right now i have this line of code in my /App/MaterialDivider.php
$provision = \Config::get('constants.MARKET_PROVISION');
and this in my \config\constants.php
return [ 'MARKET_PROVISION' => 0.3 ];
When I run artisan commands in my vagrant homestead box, this way of calling constants works within my seeder file. The problem is that I don't know how to make Laravel work when I run single file in a browser.
Apart from that, a simple
dd($var)
doesn't work either.
When working with multiple files that contain dependant classes, is it necessary to include them? Or should using 'use' be enough? Or is editing composer.json (maybe autoload-dev section?) the right choice?
So far I've been programming in C(++), so this is all very new for me, please be patient.
Partialy [SOLVED]. To anyone having similar problems: namespaces are the thing, you might be looking for.
I am writing a ZF application. I had some abstract parent classes in a library directory. Netbeans could generate test skeletons for the child classes no problems, and I could run the tests no problem.
Later on I decided to move the abstract parents out of the library and in to the application directory (to improve readability). I updated my application code accordingly, and it runs no problem.
However, now when I use netbeans to generate test skeletons for the child classes, it gives a fatal error saying it can not find the parent. I then constructed a test class manually and ran it from the command line, and PHPUnit gave the same error.
What do I need to do to get this pathing working correctly? In the PHPUnit bootstrap I tried adding the Application directory to the include path, and registering Application as a namespace with the Zend Autoloader. I don't think this is a recommended practice, and it failed anyhow...
I really do struggle with path issues, finding files, etc...
Any assistance is much appreciated.
OK, so I can move the classes from the library to the core code directories, and the core code finds them no problems because they conform to the standard naming conventions autoladed by ZF.
Other applications (e.g. PHPUnit) won't be able to find them though. I could get around this by setting their autoloading the same ZF. Alternatively, I could incorporate required files with require_once (which would negate the use of autoloading in the first place).
So, it seems that my best shot is to put the shared classes back in the library. My original PHPUnit bootstrap adds the library prefix to the ZF autoloader, so I'm good to go.
All-in-all, I've just learned another good use for libraries.
[EDIT:] Another Alternative...
My test classes are boostrapping Zend Application which sets up the autoloading for PHPUnit. The only drawback doing it this way is that PHPUnit (via my netbeans IDE) can't create the skeleton tests for me. I guess I'll have to live with that.
I would like to package PHPUnit and various other test dependencies into a phar and put that into svn. This way I can run phpunit on any client machine without needing pear. Can this be done?
Current status:
Work on a phpunit.phar has started in the phpunit repo but the generated phar is not stable and not feature complete.
If it gets there there will be official releases
Original answer:
If you can I'll give you 500 rep, a 100 Bucks and my first born.. well no.. just the first two.
To be serious:
I've nagged the creator of PHPUnit about this topic on at least 3 conferences now and well.. it doesn't seem like it's possible.
There are a couple of issues with that. First off PHPUnit spawns new php processes for test isolation. The problem with this is that a phar can't tell which php executable called it. So if you start phpunit with a custom compiled version it would use the "default" php installed to spawn the isolated tests.
Secondly as far as i know and have been told it's not possible to put static files like images and css in a phar. Which makes generating code coverage a lot harder. That would require some work on that part.
There are other issues i can't recall exactly recall right having to do with xDebug being able to provide code coverage for phars (and phpunit relying on not generating overage for it's own code and so) and others things.
There once was a phar but from my understanding that just doesn't work out with the current state of phpunit and never really worked completly.
I'm not saying it can't be done just that various people already have given up on creating a phpunit.phar including the guy how develops it. (That is just my impression, i of course can't speak for Sebastian here and might be completely wrong, take this as a little disclaimer)
Putting PHPUnit into SVN
You don't have to build a .phar to do so!
For my company I maintain a svnd version of PHPUnit. It's not the recommended way of using it but it works without much issues!
Follow the "using from a git checkout" instructions on the phpunit github site. You then need to put those files into your php include path and it works.
My suggestion would be to create a custom phpunit.sh that modifies the include path and then calls the original phpunit.sh passing along all arguments. It's a little bit of work but it works quite well and it is a hell of a lot easier than creating a phar archive :)
From the new PHPUnit page:
We distribute a PHP Archive (PHAR) that contains everything you need in order to use PHPUnit. Simply download it from here, make it executable, and put it into your $PATH, for instance......
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
I'm having issues with Zend_Gdata_YouTube.
It seems unable to locate the file VideoQuery.php despite the fact it is one of the directories mentioned in the warning messages.
Also I created a standalone version of the example just including 'Zend/Gdata/YouTube.php'. This works fine.
I've dropped the error messages then the class followed by the working example into a paste bin.
Paste Bin
I got the same error after I upgraded from ZF 1.8.0 to 1.8.4, after searching for a solution with no luck I posted my error on the ZF Gdata mail list and Trevor Johns was nice enough to get back to me with this response:
"This looks like this issue:
http://framework.zend.com/issues/browse/ZF-7013
This will be fixed in the next release of Zend Framework. If you don't
want to wait that long, you can either:
Download a development snapshot from here:
hxxp://framework.zend.com/code/browse/~tarball=zip/Zend_Framework/standard/trunk/trunk.zip
Use version 1.8.3:
hxxp://framework.zend.com/releases/ZendFramework-1.8.3/ZendFramework-1.8.3.tar.gz
Don't use Zend_Loader's autoloader functionality. (This bug only
seems to show up if you're trying to autoload the classes.)"
I'll be rolling back my ZF version until the next release.
p.s. had to substitute http with hxxp because "new users can only post a maximum of one hyperlink" apparently.
The files Zend\Gdata\Media\Extension\VideoQuery.php and Zend\Gdata\YouTube\Extension\VideoQuery.php do not exist in the framework. I think the file you want is Zend\Gdata\YouTube\VideoQuery.php
Does this help? What code is using these classes, your code or the framework code?