PHP class use other classes from composer
I made a class which autoloads with psr-4.
In this class I wanted to use classes from some libraries that I downloaded with composer the problem is that I can't seem to figure it out.
Class:
<?php
namespace CusTelegramCusCommand;
use TelegramBotActions;
use TelegramBotCommandsCommand;
class NewEpisodeCommand extends Command
{
public function handle($arguments)
{
...
$dotenv = new DotenvDotenv(__DIR__ . "/../..");
$this->replyWithMessage(['text' => __DIR__ . "/../.."]);
$dotenv->overload();
$client = new ApiVideoClientClient($_ENV["API_EMAIL"], $_ENV["API_KEY"]);
...
}
The method handle gets called from a telegram webhook so I don't know how to degub it but I'm 100% sure that it crashes when Dotenv tries to get instanciated.
Tree view:
/CusTelegram
/CusCommand
/NewEpisodeCommand.php (this class)
/bot
/bot.php
/vendor
...
In bot php I already require the autoload. This class doesn't have issues is just that I can't use DotEnv and ApiVideo in the NewEpisodeCommand class.
Bot.php:
ini_set('memory_limit', '-1');
require_once '../vendor/autoload.php';
use TelegramBotApi;
$telegram = new Api(<token>);
$commands = [CusTelegramCusCommandStartCommand::class, CusTelegramCusCommandNewEpisodeCommand::class, TelegramBotCommandsHelpCommand::class ];
$telegram->addCommands($commands);
$update = $telegram->commandsHandler(true);
--EDIT--
I was able to print the error and this is what I get:
Fatal error: Uncaught Error: Class 'CusTelegramCusCommandDotenvDotenv' not found in /membri/streamapi/CusTelegram/CusCommand/NewEpisodeCommand.php
php composer-php php-telegram-bot
add a comment |
I made a class which autoloads with psr-4.
In this class I wanted to use classes from some libraries that I downloaded with composer the problem is that I can't seem to figure it out.
Class:
<?php
namespace CusTelegramCusCommand;
use TelegramBotActions;
use TelegramBotCommandsCommand;
class NewEpisodeCommand extends Command
{
public function handle($arguments)
{
...
$dotenv = new DotenvDotenv(__DIR__ . "/../..");
$this->replyWithMessage(['text' => __DIR__ . "/../.."]);
$dotenv->overload();
$client = new ApiVideoClientClient($_ENV["API_EMAIL"], $_ENV["API_KEY"]);
...
}
The method handle gets called from a telegram webhook so I don't know how to degub it but I'm 100% sure that it crashes when Dotenv tries to get instanciated.
Tree view:
/CusTelegram
/CusCommand
/NewEpisodeCommand.php (this class)
/bot
/bot.php
/vendor
...
In bot php I already require the autoload. This class doesn't have issues is just that I can't use DotEnv and ApiVideo in the NewEpisodeCommand class.
Bot.php:
ini_set('memory_limit', '-1');
require_once '../vendor/autoload.php';
use TelegramBotApi;
$telegram = new Api(<token>);
$commands = [CusTelegramCusCommandStartCommand::class, CusTelegramCusCommandNewEpisodeCommand::class, TelegramBotCommandsHelpCommand::class ];
$telegram->addCommands($commands);
$update = $telegram->commandsHandler(true);
--EDIT--
I was able to print the error and this is what I get:
Fatal error: Uncaught Error: Class 'CusTelegramCusCommandDotenvDotenv' not found in /membri/streamapi/CusTelegram/CusCommand/NewEpisodeCommand.php
php composer-php php-telegram-bot
I can't see the problem beacuse it gets called from the telegram api since it is in a webhook and on my hosting I can't access the error log folder
– Leonardo Drici
Nov 19 '18 at 10:04
1
We won’t be able to help you if you can’t tell us the error. Consider writing tests for it, and finding a way of testing it locally.
– Thomas Edwards
Nov 19 '18 at 10:05
Is there any way to log the error on the folder that I'm on? I tried every method and It doesn't work.
– Leonardo Drici
Nov 19 '18 at 10:06
I was able to print the error
– Leonardo Drici
Nov 19 '18 at 10:58
add a comment |
I made a class which autoloads with psr-4.
In this class I wanted to use classes from some libraries that I downloaded with composer the problem is that I can't seem to figure it out.
Class:
<?php
namespace CusTelegramCusCommand;
use TelegramBotActions;
use TelegramBotCommandsCommand;
class NewEpisodeCommand extends Command
{
public function handle($arguments)
{
...
$dotenv = new DotenvDotenv(__DIR__ . "/../..");
$this->replyWithMessage(['text' => __DIR__ . "/../.."]);
$dotenv->overload();
$client = new ApiVideoClientClient($_ENV["API_EMAIL"], $_ENV["API_KEY"]);
...
}
The method handle gets called from a telegram webhook so I don't know how to degub it but I'm 100% sure that it crashes when Dotenv tries to get instanciated.
Tree view:
/CusTelegram
/CusCommand
/NewEpisodeCommand.php (this class)
/bot
/bot.php
/vendor
...
In bot php I already require the autoload. This class doesn't have issues is just that I can't use DotEnv and ApiVideo in the NewEpisodeCommand class.
Bot.php:
ini_set('memory_limit', '-1');
require_once '../vendor/autoload.php';
use TelegramBotApi;
$telegram = new Api(<token>);
$commands = [CusTelegramCusCommandStartCommand::class, CusTelegramCusCommandNewEpisodeCommand::class, TelegramBotCommandsHelpCommand::class ];
$telegram->addCommands($commands);
$update = $telegram->commandsHandler(true);
--EDIT--
I was able to print the error and this is what I get:
Fatal error: Uncaught Error: Class 'CusTelegramCusCommandDotenvDotenv' not found in /membri/streamapi/CusTelegram/CusCommand/NewEpisodeCommand.php
php composer-php php-telegram-bot
I made a class which autoloads with psr-4.
In this class I wanted to use classes from some libraries that I downloaded with composer the problem is that I can't seem to figure it out.
Class:
<?php
namespace CusTelegramCusCommand;
use TelegramBotActions;
use TelegramBotCommandsCommand;
class NewEpisodeCommand extends Command
{
public function handle($arguments)
{
...
$dotenv = new DotenvDotenv(__DIR__ . "/../..");
$this->replyWithMessage(['text' => __DIR__ . "/../.."]);
$dotenv->overload();
$client = new ApiVideoClientClient($_ENV["API_EMAIL"], $_ENV["API_KEY"]);
...
}
The method handle gets called from a telegram webhook so I don't know how to degub it but I'm 100% sure that it crashes when Dotenv tries to get instanciated.
Tree view:
/CusTelegram
/CusCommand
/NewEpisodeCommand.php (this class)
/bot
/bot.php
/vendor
...
In bot php I already require the autoload. This class doesn't have issues is just that I can't use DotEnv and ApiVideo in the NewEpisodeCommand class.
Bot.php:
ini_set('memory_limit', '-1');
require_once '../vendor/autoload.php';
use TelegramBotApi;
$telegram = new Api(<token>);
$commands = [CusTelegramCusCommandStartCommand::class, CusTelegramCusCommandNewEpisodeCommand::class, TelegramBotCommandsHelpCommand::class ];
$telegram->addCommands($commands);
$update = $telegram->commandsHandler(true);
--EDIT--
I was able to print the error and this is what I get:
Fatal error: Uncaught Error: Class 'CusTelegramCusCommandDotenvDotenv' not found in /membri/streamapi/CusTelegram/CusCommand/NewEpisodeCommand.php
php composer-php php-telegram-bot
php composer-php php-telegram-bot
edited Nov 19 '18 at 10:58
Leonardo Drici
asked Nov 19 '18 at 10:00
Leonardo DriciLeonardo Drici
6019
6019
I can't see the problem beacuse it gets called from the telegram api since it is in a webhook and on my hosting I can't access the error log folder
– Leonardo Drici
Nov 19 '18 at 10:04
1
We won’t be able to help you if you can’t tell us the error. Consider writing tests for it, and finding a way of testing it locally.
– Thomas Edwards
Nov 19 '18 at 10:05
Is there any way to log the error on the folder that I'm on? I tried every method and It doesn't work.
– Leonardo Drici
Nov 19 '18 at 10:06
I was able to print the error
– Leonardo Drici
Nov 19 '18 at 10:58
add a comment |
I can't see the problem beacuse it gets called from the telegram api since it is in a webhook and on my hosting I can't access the error log folder
– Leonardo Drici
Nov 19 '18 at 10:04
1
We won’t be able to help you if you can’t tell us the error. Consider writing tests for it, and finding a way of testing it locally.
– Thomas Edwards
Nov 19 '18 at 10:05
Is there any way to log the error on the folder that I'm on? I tried every method and It doesn't work.
– Leonardo Drici
Nov 19 '18 at 10:06
I was able to print the error
– Leonardo Drici
Nov 19 '18 at 10:58
I can't see the problem beacuse it gets called from the telegram api since it is in a webhook and on my hosting I can't access the error log folder
– Leonardo Drici
Nov 19 '18 at 10:04
I can't see the problem beacuse it gets called from the telegram api since it is in a webhook and on my hosting I can't access the error log folder
– Leonardo Drici
Nov 19 '18 at 10:04
1
1
We won’t be able to help you if you can’t tell us the error. Consider writing tests for it, and finding a way of testing it locally.
– Thomas Edwards
Nov 19 '18 at 10:05
We won’t be able to help you if you can’t tell us the error. Consider writing tests for it, and finding a way of testing it locally.
– Thomas Edwards
Nov 19 '18 at 10:05
Is there any way to log the error on the folder that I'm on? I tried every method and It doesn't work.
– Leonardo Drici
Nov 19 '18 at 10:06
Is there any way to log the error on the folder that I'm on? I tried every method and It doesn't work.
– Leonardo Drici
Nov 19 '18 at 10:06
I was able to print the error
– Leonardo Drici
Nov 19 '18 at 10:58
I was able to print the error
– Leonardo Drici
Nov 19 '18 at 10:58
add a comment |
1 Answer
1
active
oldest
votes
I was able to fix the error I just needed to insert the use path like:
use DotenvDotenv;
use ApiVideoClientClient;
1
If you didn't want to use theuse
statement, you would have to prefix the FQCN with a backslash like this:$dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372183%2fphp-class-use-other-classes-from-composer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was able to fix the error I just needed to insert the use path like:
use DotenvDotenv;
use ApiVideoClientClient;
1
If you didn't want to use theuse
statement, you would have to prefix the FQCN with a backslash like this:$dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
add a comment |
I was able to fix the error I just needed to insert the use path like:
use DotenvDotenv;
use ApiVideoClientClient;
1
If you didn't want to use theuse
statement, you would have to prefix the FQCN with a backslash like this:$dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
add a comment |
I was able to fix the error I just needed to insert the use path like:
use DotenvDotenv;
use ApiVideoClientClient;
I was able to fix the error I just needed to insert the use path like:
use DotenvDotenv;
use ApiVideoClientClient;
answered Nov 19 '18 at 11:04
Leonardo DriciLeonardo Drici
6019
6019
1
If you didn't want to use theuse
statement, you would have to prefix the FQCN with a backslash like this:$dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
add a comment |
1
If you didn't want to use theuse
statement, you would have to prefix the FQCN with a backslash like this:$dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
1
1
If you didn't want to use the
use
statement, you would have to prefix the FQCN with a backslash like this: $dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
If you didn't want to use the
use
statement, you would have to prefix the FQCN with a backslash like this: $dotenv = new DotenvDotenv(__DIR__ . "/../..");
– xabbuh
Nov 20 '18 at 11:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372183%2fphp-class-use-other-classes-from-composer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I can't see the problem beacuse it gets called from the telegram api since it is in a webhook and on my hosting I can't access the error log folder
– Leonardo Drici
Nov 19 '18 at 10:04
1
We won’t be able to help you if you can’t tell us the error. Consider writing tests for it, and finding a way of testing it locally.
– Thomas Edwards
Nov 19 '18 at 10:05
Is there any way to log the error on the folder that I'm on? I tried every method and It doesn't work.
– Leonardo Drici
Nov 19 '18 at 10:06
I was able to print the error
– Leonardo Drici
Nov 19 '18 at 10:58