V
V
Vit2016-08-09 20:18:55
Composer
Vit, 2016-08-09 20:18:55

How to add a class in composer?

There is a module structure in the vendor folder:
6cf1e5b73a724a74a942fdd19dcbded3.png
In composer.json:

{
  "name": "test/log",
  "description": "",
  "type": "library",
  "license": "MIT",
  "minimum-stability": "dev",
  "require": {
    "php": "^5.6 || ^7.0"
  },
  "autoload": {
    "psr-4": {
      "Log\\": "src/"
    }
  }
}

In Log.php:
<?php

namespace Testspace;

class Log
{
    public static function test()
    {
        echo 1;
    }
}

In the controller I write: \Testspace\Log::test(); and I get an error:
2043af1d07294c3dbb4fe8b9f23cad65.png
composer dump-autoload did, does not help. What could be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philipp, 2016-08-09
@zoonman

The Log.php file should be in the Testspace folder.
/vendor/test/log/src/Testspace/Log.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question