L
L
lotrop2016-12-19 21:57:17
PHP
lotrop, 2016-12-19 21:57:17

How to include a class with autoload, which does not have namespaces?

Hello. There is a project in which I use the Pchart library.
Connected it via composer. Inside this library is the following json file:

{
    "name": "dmelo/pchart",
    "description": "pChart is a PHP library that will help you to create anti-aliased charts or pictures directly from your web server. You can then display the result in the client browser, sent it by mail or insert it into PDFs. pChart provide object oriented coding syntax and is fully in line with the new web standards allowing you to enhance your web2.0 applications.",
    "type": "library",
    "homepage": "http://www.pchart.net/",
    "autoload": {
        "psr-0": {
            "": "./library/"
        }
    },
    "include-path": [
        "library/"
    ]
}

Everything is fine if I use the classes of this library just in php files. But if I want to create a class of this library inside the class of my project, then an error is thrown: class not found.
How to be here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arman, 2016-12-19
@lotrop

what prevents to connect from the global scope?

<?php

namespace MyApp;

use \Pchart_Class;

class MyClass
{
    public function setClass(Pchart_Class $pchartClass)
    {
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question