oop - PHP extending a namespaced library -


What is the best way to expand a library in PHP?

I am using the library. In my code, I instantiate the library like this:

  //// OAuth2 server is required ('./aauth2-server-php / src / OAuth2 / Autoloader.php '); OAuth2 \ Autoloader :: Register ();  

There are all OAuth2 classes under the namespace starting with OAuth2 \ foo \ bar; I am able to give these classes a unique name for my own classes without specifying the namespace (Which I do not like to do). However, I want to make my namespace in order to keep the actual class names in my expanse. For example, when I try to expand the PWO class like this, then it says, 'Class PEDA is already instant'.

I therefore tried it in MyServer.php, I have:

  & lt ;? Php namespace mines; Class server OAuth2 \ Server {}? & Gt;  

But then I get an error that class MyNS \ OAuth2 \ server does not exist . Obviously, this is not it, and I do not think you can go up a level with the names as you can with the directory.

I have spent the proper time reading the docs for PHP classes. I can rename those classes by changing them (for example MyServer or MyPdo), but this is dirty and I think I should use my name space or even MyNS \ OAuth2 could work if I knew how to do this. Maybe I have to create my own auto-load for class (which I do not know how to do)?

Can someone shine light in my mind?

You were almost with your own name space - you would get an extra backslash \ so that you can ensure that you are sitting in OAuth2 - ie.

  & lt; Php namespace mien; Class server \ OAuth2 \ Server {/ ^ ^ ______________________ extends here}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -