Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
43 views

Namespace in php application

I am trying to manage my code in a sample code to learn. I have a sample application whose dir structure is as follow -Sample --bootstrap --app --class1.php --class2.php --class3.php --config --...
user269867's user avatar
  • 3,912
2 votes
2 answers
1k views

Eclipse: Automatically add "use namespace"

I am refactoring a big PHP project (more than 500 PHP files) into namespace tree structure. Is there a way to get Eclipse PDT automatically add use ... at the top of the file when an undefined class ...
Marco's user avatar
  • 779
0 votes
2 answers
787 views

Duplicate Namespaces in PHP?

I'm new to namespaces and curious whether it's possible for there to be duplicates. For example, I'm working in a Wordpress environment using a popular script in my plugin. This plugin uses a ...
Damon Malkiewicz's user avatar
0 votes
2 answers
729 views

PHP autoloader with namespaces [duplicate]

I am trying to understand how to define a working autoloader for a trivial application with namespaces. I created following structure: public index.php src Models WordGenerator.php ...
Tomasz Kapłoński's user avatar
1 vote
1 answer
1k views

PHP ImageWorkshop package with Composer failing

So very strange issue. I only recently starting using auto loading in PHP 5.3+ and of course, this inevitably led to composer. I did a really simple install with composer with only one package, php ...
Daniel Saint James's user avatar
2 votes
3 answers
1k views

PHP: How to access a namespace class with :: instead of \?

I use namespace for a class like this below, class_tidy.php, namespace foo; class tidy { public function hello() { echo 'Hello'; } } index.php, class MyAutoloader { public ...
Run's user avatar
  • 57.1k
0 votes
2 answers
116 views

PHP Namespaces: If I'm not going to need to redeclare already taken functions do I need them?

I'm wondering, that if my functions don't have similar names, do I need to use namespaces? plus I can't get the grips of importing all namespaces from a specific folder...
user avatar
0 votes
1 answer
852 views

Why does doctrine 2.2 use -namespace- and -use- without any include or require statement?

I am studying namespace in php and Doctrine 2.2 for a week. I explorered several blogs and read several articles about namespace in php. I understand that, when we want to use different namepaces ...
Yunus Ekiz's user avatar
0 votes
1 answer
864 views

PHP different path names spaces and autoloading not working

I'm trying to implement autoloading in Php5.3 using namespaces but I'm having some issues and don't know why it's not working. I have a basic directory structure of /root --bootstrap.php --test.php -...
TheStoneFox's user avatar
  • 3,047
4 votes
1 answer
518 views

Why does this PHP method declaration not recognize the namespace of the type hint?

I'm trying to write a library based on Doctrine Extensions, which provides this interface: namespace Gedmo\Mapping; use Doctrine\Common\Persistence\Mapping\ClassMetadata; interface Driver { ...
Andrew Vit's user avatar
  • 19.2k
3 votes
3 answers
3k views

Exception Thrown In Parent Class Not Caught In Child Class

This error is happening when using the Facebook PHP SDK but I actually think it's a general error. When I run this code, everything works fine and the exception is caught: $facebook = new Facebook('...
derekbeau's user avatar
2 votes
2 answers
2k views

Lead backslash at the beginning of dynamic class name

The code: $className = '\MyNamespace\MyClass'; $object = new $className(); throws error 'Class not found' But this code: $object = new \MyNamespace\MyClass(); is not. First code fragment works ...
sneas's user avatar
  • 1,062
6 votes
2 answers
2k views

PHP namespaces: equivalent to C# using

What is the equivalent of C#'s using Name.Space; statement to make all classes of that namespace available in the current file? Is this even possible with PHP? What I'd like (but does not work): <...
knittl's user avatar
  • 264k
3 votes
2 answers
1k views

autoload and namespaces

I've been working with PHP for a long time, but am now starting to experiment with newer language features such as namespaces. I have a question regarding autoloading that I haven't been able to find ...
GordonM's user avatar
  • 31.7k
6 votes
2 answers
754 views

PHP namespaced function best practices

I have a few general use functions that do not really make sense in any class as static methods. I would like to encapsulate them under a namespace so there are no conflicts with functions defined in ...
rr.'s user avatar
  • 6,634
0 votes
1 answer
954 views

Doctrine 2 autoloader

$modelsClassLoader = new ClassLoader('Application\Model', __DIR__ . '/models'); $modelsClassLoader->register(); This will try to load \Application\Model\User in my/application/models/Application/...
Matthieu Napoli's user avatar
2 votes
2 answers
888 views

PHP namespace organisation, naming

I am facing the following problem : I have a namespace Exception\*, which contains several types of exceptions. I have a namespace Exception\User\*, which contains a specific kind of exceptions (...
Matthieu Napoli's user avatar
8 votes
3 answers
2k views

PHP namespaces : \My\Namespace or My\Namespace?

My\Namespace \My\Namespace So, which one should I use, I see the php documentation uses mostly My\Namespace. But it is said that \My\Namespace is better, because non ambiguous, whereas My\Namespace ...
Matthieu Napoli's user avatar
5 votes
2 answers
1k views

Is @package required with PHP 5.3 namespaces?

I've switched to PHP 5.3 and the namespaces. It seems like the @package tag is redundant and useless now. Is it still required by phpDoc, or can I ignore this tag now ? Thanks
Matthieu Napoli's user avatar
2 votes
1 answer
1k views

Dynamically Loading Namespaced Classes

I'm working on a Data Mapper framework for PHP that will use Namespaces and rely exclusively on PHP5.3. In order to allow others to use the framework and extend its inner components as needed, I'd ...
Noah Goodrich's user avatar