I have own project and i would like add for this class same as in Jobeet tutorial:
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/05
I copied exactly same as in this article, but i have error:
Fatal error: Call to undefined method Jobeet::slugify()
Any own class for /lib is not included in my actions, but methods getTable, from Doctrine etc working. Not working only my class for all folder /lib. Why? How can i enable this?
First, do you have this file: Jobeet.class.php ?
Second, this is strange because by default, classes stored in the following directories in your projects benefit from the autoloading automatically:
myproject/lib/
myproject/lib/model
myproject/apps/frontend/lib/
myproject/apps/frontend/modules/mymodule/lib
You can force the autoload when you need to load lib from other folders. Check the doc for that (this is for sf1.2 but it's work for 1.4).
Related
My root project folder is:
c:\phpproject\data_valid.php
In this folder I have a library I need to use:
c:\phpproject\vendor\egulias\email-validator\src\EmailValidator.php
Inside data_valid.php I include the library I need:
//data_valid.php
include ('vendor\egulias\email-validator\src\EmailValidator.php');
The EmailValidator.php has dependencies:
//EmailValidator.php
namespace Egulias\EmailValidator;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Validation\EmailValidation;
When I run the data_valid.php script I get the error:
Fatal error: Uncaught Error: Class "Egulias\EmailValidator\EmailLexer"
So, the data_valid.php file doesn't know where the EmailLexer.php is, being this file called from EmailValidation.php. If I include EmailLexer.php in data_valid.php it is found
//data_valid.php
include ('vendor\egulias\email-validator\src\EmailValidator.php');
include ('vendor\egulias\email-validator\src\EmailLexer.php');
But more dependendencies are missing:
Fatal error: Uncaught Error: Class "Doctrine\Common\Lexer\AbstractLexer
It seems that PHP doesn't include the dependencies of a library automatically.
How do I do that?
PD. After some research I found that including:
include 'vendor/autoload.php';
It loads everything.
But I am still curious how to do it without using include 'vendor/autoload.php'. For example, I have a bunch of classes inside multiple files in a directory. In this scenario I need to call one class but that class depends in multiple classes defined in multiple files in that directory.
Use composer: https://getcomposer.org/
It also allows for manual inclusion of custom classes etc.
I don't recommend manually including all the necessary classes as you would need some recursive search for this anyway.
I have defined constant.php file inside app folder like app/constant.php.
And I have defined my upload url like:
define('DIR_UPLOADS', url('/').'/uploads/');`
but it throws the following error:
Call to a member function make() on null in
C:\xampp\htdocs\rabble\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php
on line 53
I have also created a new folder named uploads and I'm using Laravel 5.1. I have also tried composer update and composer dump-auto.
What is causing this error and how do I fix it?
When config files are loaded the container is not yet fully initialized. When you call url() helper, it's trying to get UrlGenerator service from the container, but the container instance does not exist yet.
You should also use Config facade to store/retrieve global settings instead of defining PHP constants.
What do you want to use this constant for? Please elaborate and I'll find a better place to put it.
I have createsd a new module in prestashop. Here I had overrite some core functionality of product class.
My overrite file has placed in the location : prestashop/modules/mymodule/override/
When I install the module i am getting the following Error :
Cannot redeclare class ProductOverrideOriginal in /var/www/html/htdocs/prestashop/modules/sharesoft_relatedproducts/sharesoft_relatedproducts.php(96) : eval()'d code on line 2
[PrestaShop] Fatal error in module sharesoft_relatedproducts.php(96) : eval()'d :
Cannot redeclare class ProductOverrideOriginal .
How can i fix this
It means jsut what it says. Your code tries to declare a class twice (with the same), so there is a conflict.
I also do not understand why your class is named ProductOverrideOriginal. All Prestashop overrides must override original PrestaShop classes, for example
class Product extends ProductCore { ...
From the error message I presume that you tried to include your overriden class
require('/override/sharesoft_relatedproducts.php');
But all files from module folder
prestashop/modules/mymodule/override/
are automatically copied to
prestashop/override/
during module installation. My guess is that your override class file is copied there, and is loaded, but you also try to include it again in your module, which gives you error (trying to declare twice).
Also, make sure you use statements like:
require_once('myfile.php');
or
if (!class_exists('MyFile'))
require_once('myfile.php');
to ensure that the same class is not declared twice. Seconde option is better because its faster (does not check file system)
I am trying to get PHPUnit (for TDD) working with CodeIgniter.
A perfectly reasonable guide that I am following is here: http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans
But the problem I am getting is this:
c:\projects\project1\tests>phpunit .
Fatal error: Call to undefined function get_instance() in c:\....\PostTest.php on line 7
which almost sounds like my whole CodeIgniter framework is not being seen.
I've modified the bootstrap.php file to have an explicit path to the system and application folders, just to be sure that it's not something simple like that. But no luck.
What does get_instance depend on to run? It's part of the core CodeIgniter framework.
I got the same error.
The problem is in the file phpunit.xml
You need to place it on
c:\projects\project1\tests>
and you need to create the file bootstrap.php as on your link :
http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans
that's how your tests connect to your codeigniter
I'm trying to use this extension
But it gives me the following error when loading the library:
Unable to load the requested class: Language
Also if I write MY_Language instead, it gives me the following error:
Fatal error: Class 'CI_Language' not found in C:\wamp\www\ckphp\application\libraries\MY_Language.php on line 79
I am using WAMP and CI v. 2.2.0
Thanks!
I figured it out myself after some more researching...
Apparently the language class is not even in the library folder, but in core folder, meaning it should be placed in the core application/core folder. Also the name is not CI_Language, but CI_Lang, meaning the file name has to be MY_Lang (if MY_ is your prefix). The last thing to change in the extension is
parent::CI_Language();
to
parent::__construct();
and everything should work fine!
Usage:
$this->lang->load('set', 'language'); // To load a language
$this->lang->line('key'); // to display the text
or simply
lang('key'); // if using the language helper
Hope this will help others in the future!
I made a GIST for latest CodeIgniter 3.1.X including with migration to create the database structure
https://gist.github.com/cyberfly/885b320fdf914ae15f7316b22cc72f32