Closed dirkplatts closed 9 years ago
not sure wether this has something to do with namespaces, it is just frustrating i can't get this simple template running
Test hast an issue also... Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /blablapath/template/EngineTest.php on line 8
That's weird. What version of Plates are you using?
I'm using 3.1.0
installed by downloading, unzipping, uploading to webserver. tried many different paths, though I believe it shouldn't be causing this error when just doing this:
require_once('../template/Engine.php'); $templates = new League\Plates\Engine('anypathreally');
right?
no fancy webserver confg or anything afaik. it is on a shared hosting and I am just not sure if there might be some restrictions regarding namespaces. does that make sense?
Right, it sounds to me like an autoloading issue. You can download Plates on it's own, but then you need to wire up the class autoloading on your own. Plates does not come with autoloading itself. It makes more sense to use something like Composer.
To manually include all the Plates classes you could do something like this:
require_once('/plates/src/Engine.php');
require_once('/plates/src/Template/Data.php');
require_once('/plates/src/Template/Directory.php');
require_once('/plates/src/Template/FileExtension.php');
require_once('/plates/src/Template/Folder.php');
require_once('/plates/src/Template/Folders.php');
require_once('/plates/src/Template/Func.php');
require_once('/plates/src/Template/Functions.php');
require_once('/plates/src/Template/Name.php');
require_once('/plates/src/Template/Template.php');
require_once('/plates/src/Extension/Asset.php');
require_once('/plates/src/Extension/ExtensionInterface.php');
require_once('/plates/src/Extension/URI.php');
However, again, I would highly recommend using Composer. Alternatively you could use any valid PSR-4 autoloader. For example, Aura.Autoload.
Good luck!
Thanks, I will check it out
Happy to help! Good luck! :)
All those files will be included no matter if I use composer or not right? Will carry around unneccessary overhead otherwise I guess.
Because I installed with composer and still receive the same "Fatal error: Class 'League\Plates\Template\Directory' not found in /blapath/vendor/league/plates/src/Engine.php on line 57"
All those files will be included no matter if I use composer or not right? Will carry around unneccessary overhead otherwise I guess.
Exactly, you don't need to include them manually if you're using Composer. The beauty of autoloading is that only the files you need are included.
Because I installed with composer and still receive the same "Fatal error: Class 'League\Plates\Template\Directory' not found in /blapath/vendor/league/plates/src/Engine.php on line 57"
Are you including the Composer autoload file? Something like:
include 'vendor/autoload.php';
It is running now, I forgot the autoload. Many thanks for your support here. Guess I will need to get comfortable with composer since I see more and more projects making use of it. Just didn't quite get the hang of it yet ;)
@dcp Definitely do! It takes a little bit of getting used to, but you'll never look back.
Fatal error: Class 'League\Plates\Template\Directory' not found in/template/Engine.php on line 57
I keep on receiving this error. No matter if I use absolute or relative path:
$templates = new League\Plates\Engine('/mypath/template');