I have to send a number to my Arduino using the COM port using PHP. I included phpSerial class to do that. Included the PhpSerial.php containing the class phpSerial class to the PHP code. I am getting an error : Fatal error: Uncaught Error: Class 'phpSerial' not found in C:\Apache24\htdocs\kprientvaegan\ref\com.php:4 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\kprientvaegan\ref\com.php on line 4.
Could anyone please help me to fix this?
<?php
include 'PhpSerial.php';
$serial = new phpSerial;
$serial ->deviceSet("COM1"); //Port number
$serial ->confbaudRate(9600);
$serial ->confParity("none");
$serial ->confCharacterLength(8);
$serial ->confStopBits(1);
$serial ->confFlowControl("none");
$serial ->deviceOpen();
$serial ->sendMessage('1');
$serial ->deviceClose();
?>
Fatal error: Uncaught Error: Class 'phpSerial' not found in C:\Apache24\htdocs\kprientvaegan\ref\com.php:4 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\kprientvaegan\ref\com.php on line 4.
I suggest to use pyserial module with python. It is very easy and powerful.
You can to download this module from here:
pyserial module link
And this is the documentation:
pyserial documentation
Related
I'm trying to use google_ads_api to generate keywords idea.
I found an error when I execute generateKeywordsIdeas.php file.
PS C:\xampp\htdocs\google_ads_api> php GenerateKeywordIdeas.php
PHP Fatal error: Uncaught Error: Class 'Google\Ads\GoogleAds\Examples\Utils\ArgumentParser' not found in C:\xampp\htdocs\google_ads_api\GenerateKeywordIdeas.php:67
Stack trace:
#0 C:\xampp\htdocs\google_ads_api\GenerateKeywordIdeas.php(212): Google\Ads\GoogleAds\Examples\Planning\GenerateKeywordIdeas::main()
#1 {main}
thrown in C:\xampp\htdocs\google_ads_api\GenerateKeywordIdeas.php on line 67
Fatal error: Uncaught Error: Class 'Google\Ads\GoogleAds\Examples\Utils\ArgumentParser' not found in C:\xampp\htdocs\google_ads_api\GenerateKeywordIdeas.php:67
Stack trace:
#0 C:\xampp\htdocs\google_ads_api\GenerateKeywordIdeas.php(212): Google\Ads\GoogleAds\Examples\Planning\GenerateKeywordIdeas::main()
#1 {main}
thrown in C:\xampp\htdocs\google_ads_api\GenerateKeywordIdeas.php on line 67
Here is file structure of my project
Why this error happens..? can anybody explain..?
Sounds like your missing required files from the 'examples' directory? They're excluded from the ZIP when you download the package from github. You can grab them here:
https://downgit.github.io/#/home?url=https://github.com/googleads/google-ads-php/tree/master/examples
I'm stuck with building a Google login page without composer.
What i have so far is:
require_once 'google-api-php-client-1-master/src/Google/autoload.php';
define('GOOGLE_CLIENT_ID', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
define('GOOGLE_CLIENT_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxx');
define('GOOGLE_REDIRECT_URL', 'https://url to page after login');
$gClient = new Google_Client();
$gClient->setApplicationName('Inlog PROJECTNAME');
$gClient->setClientId(GOOGLE_CLIENT_ID);
$gClient->setClientSecret(GOOGLE_CLIENT_SECRET);
$gClient->setRedirectUri(GOOGLE_REDIRECT_URL);
$google_oauthV2 = new Google_Oauth2Service($gClient);
I downloaded this library from Github and included it as above, i saw this error:
Fatal error: Uncaught Error: Class 'Google_Oauth2Service' not found in /home/xxxxxxx/domain/xxxxxxxx/public_html/includes/google-login.config.php:46 Stack trace: #0 /home/xxxxxxx/domains/xxxxxxxxxx/public_html/google-login.php(5): require_once() #1 {main} thrown in /home/xxxxxxx/domains/xxxxxxxxxxx/public_html/includes/google-login.config.php on line 46
How can i fix this without the use off composer?? Thanks in advance!!
I'm trying to create a database using composer. I've demo.php as the main file and running the code on localhost.
Error message :
Fatal error: Uncaught
MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable
servers found (serverSelectionTryOnce set): [socket timeout calling
ismaster on '127.0.0.1:27017'] in
C:\xampp\htdocs\phpmongodb\vendor\mongodb\mongodb\src\Database.php:201
Stack trace: #0
C:\xampp\htdocs\phpmongodb\vendor\mongodb\mongodb\src\Database.php(201):
MongoDB\Driver\Manager->selectServer(Object(MongoDB\Driver\ReadPreference))
1 C:\xampp\htdocs\phpmongodb\demo.php(8): MongoDB\Database->createCollection('emplcollection') 2 {main} thrown
in C:\xampp\htdocs\phpmongodb\vendor\mongodb\mongodb\src\Database.php
on line 201
What could be the reason for this?
My code:
<?php
require 'vendor/autoload.php';
$client = new MongoDB\Client;
$companydb = $client->companydb;
$result1 = $companydb->createCollection('emplcollection');
var_dump(result1);
?>
i want to use https://packagist.org/packages/smochin/instagram-php-crawler
i downloaded that and i made index.php in project
index.php :
<?php
$insta = new Smochin\Instagram\CrawlerTest;
i have this error but i dont know why !
Fatal error: Uncaught Error: Class 'Smochin\Instagram\CrawlerTest' not
found in E:\xamppN\htdocs\insta\index.php:10 Stack trace: #0 {main}
thrown in E:\xamppN\htdocs\insta\index.php on line 10
You just need to add following line to your code
require_once DIR . '/vendor/autoload.php';
Already installed library using composer
Я уже установил библиотеку через composer
composer require vkcom/vk-php-sdk
But cant initializate it by
однако не выходит её инициализировать через
$vk = new VKApiClient();
Recieve error
Получаю ошибку
Fatal error: Uncaught Error: Class 'VKApiClient' not found in E:\OSPanel\domains\localhost\albom.php:2 Stack trace: #0 {main} thrown in E:\OSPanel\domains\localhost\albom.php on line 2
Directory hierarchy image
Изображение иерархии директорий
I already tried method below:
Также я пробовал способ ниже:
$vk = new \vkapi\src\VK\Client\VKApiClient();
But receive error:
Но получаю ошибку:
Fatal error: Uncaught Error: Class 'vkapi\src\VK\Client\VKApiClient' not found in E:\OSPanel\domains\localhost\albom.php:2 Stack trace: #0 {main} thrown in E:\OSPanel\domains\localhost\albom.php on line 2
Tried use require for composer autoload file, but it still doesnt works well
Уже пробовал использовать require для автозагрузочного файла composer'a, но это всё равно не работает
require '.\vendor\autoload.php';
$vk = new VKApiClient();
Recieve error
Получаю ошибку
Fatal error: Uncaught Error: Class 'VKApiClient' not found in E:\OSPanel\domains\localhost\albom.php:3 Stack trace: #0 {main} thrown in E:\OSPanel\domains\localhost\albom.php on line 3
There are different points here.
First, VKApiClient's namespace is not \vkapi\src\VK\Client\. You can open a file and read the code. It doesn't contain src at all, it does contain namespace VK\Client, so you can initialize client this way
$vk = new \VK\Client\VKApiClient();
Second, you have to include source file. Composer does it via autoload.php. If is not actual somehow, try php composer dump-autoload to refresh autoload file.
Actually, you'd better use English only. Russian SO is here. Have you tried to ask your question there? Though audience is much greater here, I prefer English SO rather that Russian.