Im testing out something in laravel but the code below gives me error and I couldnt figure out whats the problem
Code :
<?php
require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
$posts = \App\Models\Post::take(5)->get()->toArray();
file_put_contents('1.txt', print_r($posts, 1));
>
error :
Fatal error: Uncaught Error: Call to a member function connection() on null in /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:3351 Stack trace: #0 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3317): Illuminate\Database\Eloquent\Model::resolveConnection(NULL) #1 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1861): Illuminate\Database\Eloquent\Model->getConnection() #2 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1834): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder() #3 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1804): Illuminate\Database\Eloquent\Model->newQueryWithoutScopes() #4 /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(3561): Illuminate\Database\Eloquent\Model->newQuery() #5 /home/vowave/public_html/vendor/laravel/framework/sr in /home/vowave/public_html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 3351
When you manually start laravel, you should call bootstrap method , like this:
<?php
$app = require __DIR__.'/bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
var_dump(Task::all());
Related
I am using google-play-scraper. but I am getting below error while using it.
Fatal error: Uncaught Error: Call to undefined method Symfony\Component\BrowserKit\Response::getStatus() in C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Client.php:15 Stack trace: #0 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\symfony\browser-kit\AbstractBrowser.php(401): Raulr\GooglePlayScraper\Client->filterResponse(Object(Symfony\Component\BrowserKit\Response)) #1 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Scraper.php(367): Symfony\Component\BrowserKit\AbstractBrowser->request('GET', 'https://play.go...') #2 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Scraper.php(108): Raulr\GooglePlayScraper\Scraper->request('/store/apps/det...', Array) #3 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\examples\app.php(10): Raulr\GooglePlayScraper\Scraper->getApp('com.google.andr...') #4 {main} thrown in C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Client.php on line 15
After getting this error I try the below solution.
Solution URL: https://github.com/raulr/google-play-scraper/issues/35
`[Change getStatus() to getStatusCode() ]
vendor\raulr\google-play-scraper\src\Client.php
Line: 15
$response->getStatus()
to
$response->getStatusCode()
vendor\raulr\google-play-scraper\src\Scraper.php
Line: 368
$status_code = $this->client->getResponse()->getStatus();
to
$status_code = $this->client->getResponse()->getStatusCode();`
but it did not work for me.
Hello i am trying to make connection to firebase database from php and i have this code
<?php
require __DIR__.'/vendor/autoload.php';
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile(__DIR__ . '/secret/sajilo-entrance-med-firebase-adminsdk-1bta4-487ebfe276.json');
$factory = (new Factory)->withServiceAccount($serviceAccount);
$firebase = (new Factory)
->withServiceAccount('$serviceAccount')
->withDatabaseUri('https://sajilo-entrance-med.firebaseio.com/')
->create();
$database = $firebase->getDatabase();
?>
and i am getting this error
Fatal error: Uncaught TypeError: Argument 1 passed to Kreait\Firebase\Factory::withServiceAccount() must be an instance of Kreait\Firebase\ServiceAccount, string given, called in C:\xampp\htdocs\MedEntrance\dbconfig.php on line 10 and defined in C:\xampp\htdocs\MedEntrance\vendor\kreait\firebase-php\src\Firebase\Factory.php:77 Stack trace: #0 C:\xampp\htdocs\MedEntrance\dbconfig.php(10): Kreait\Firebase\Factory->withServiceAccount('$serviceAccount') #1 C:\xampp\htdocs\MedEntrance\insert_test.php(43): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\MedEntrance\vendor\kreait\firebase-php\src\Firebase\Factory.php on line 77
Try change withServiceAccount('$serviceAccount') to withServiceAccount($serviceAccount)
When a query is made, it retuns 404, invalid json error.
I use 8083 as port. Is there any another port for api.
Below is the code I use. Any help is welcome.
<?php
require '/vendor/autoload.php';
$client = new InfluxDB\Client('153.148.25.44', '8083');
$database = $client->selectDB('Meters');
$result = $database->getQueryBuilder()
->select('*')
->from('GDATA')
->limit(2)
->getResultSet()
->getPoints();
//$result = $database->query('select * from GDATAlimit LIMIT 5;');
//$points = $result->getPoints();
//$lastQuery = $client->getLastQuery();
echo '<pre>';
var_dump($result);
?>
Tested database connection, it is working.
Version is 0.13
Fatal error:
Uncaught exception 'InvalidArgumentException' with message 'Invalid JSON' in C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\ResultSet.php:30
Stack trace: #0 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Driver\Guzzle.php(100): InfluxDB\ResultSet->__construct('404 page not fo...')
#1 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Client.php(198): InfluxDB\Driver\Guzzle->query()
#2 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Database.php(78): InfluxDB\Client->query('Meters', 'SELECT * FROM "...', Array)
#3 C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\Query\Builder.php(261): InfluxDB\Database->query('SELECT * FROM "...')
#4 C:\xampp\htdocs\projectone\home.php(10): InfluxDB\Query\Builder->getResultSet()
#5 {main} thrown in C:\xampp\htdocs\projectone\vendor\influxdb\influxdb-php\src\InfluxDB\ResultSet.php on line 30
API port for InfuxDB v0.13 is 8086. I was using 8083, which is used for web.
I am trying to get Mink working on Centos/Apache, but it cannot connect. I have tried with Selenium2Driver, ZombieDriver and last Sahi but I always get a different error.
Right now with Sahi:
require __DIR__ . '/vendor/autoload.php';
$driver = new \Behat\Mink\Driver\SahiDriver('firefox');
$session = new \Behat\Mink\Session($driver);
$session->start();
$session->visit('http://google.it');
echo $session->getStatusCode();
and generate this error:
Fatal error: Uncaught exception 'Buzz\Exception\RequestException' with
message 'couldn't connect to host' in
/var/www/html/Test/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php:29
Stack trace: #0
/var/www/html/Test/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(130):
Buzz\Client\Curl->send(Object(Buzz\Message\Request),
Object(Buzz\Message\Response)) #1
/var/www/html/Test/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(82):
Buzz\Browser->send(Object(Buzz\Message\Request)) #2
/var/www/html/Test/vendor/kriswallsmith/buzz/lib/Buzz/Browser.php(36):
Buzz\Browser->call('http://localhos...', 'POST', Array, '') #3
/var/www/html/Test/vendor/behat/sahi-client/src/Connection.php(268):
Buzz\Browser->post('http://localhos...', Array, '') #4
/var/www/html/Test/vendor/behat/sahi-client/src/Connection.php(150):
Behat\SahiClient\Connection->post('http://localhos...') #5
/var/www/html/Test/vendor/behat/sahi-client/src/Client.php( in
/var/www/html/Test/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php
on line 29
I have installed with composer:
behat/behat
behat/mink
behat/mink-sahi-driver
behat/sahi-client
Why it cannot connect?
I have PHP code that is managing mailing lists using the Provisioning API. Visitors are able to opt in or out of the mailing list via a web form. It has been working for ~6 months and stopped working 10/1/2013.
I am using this code for testing:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$service = Zend_Gdata_Gapps::AUTH_SERVICE_NAME ;
$username = 'my_username';
$password = 'my_password';
$domain = 'my_domain';
$email = 'test-email#domain.com';
$email_list = 'test-list';
$client = Zend_Gdata_ClientLogin::getHttpClient($username, $password, $service);
$gdata = new Zend_Gdata_Gapps($client, $domain);
$gdata->addRecipientToEmailList($email, $email_list);
I'm receiving the following error message:
PHP Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400
Invalid request URI' in /usr/share/php/Zend/Gdata/App.php:716\nStack trace:
#0 /usr/share/php/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'https://apps-ap...', Array, '<atom:entry xml...', 'application/ato...', NULL)
#1 /usr/share/php/Zend/Gdata/App.php(908): Zend_Gdata->performHttpRequest('POST', 'https://apps-ap...', Array, '<atom:entry xml...', 'application/ato...')
#2 /usr/share/php/Zend/Gdata/Gapps.php(247): Zend_Gdata_App->post(Object(Zend_Gdata_Gapps_EmailListRecipientEntry), 'https://apps-ap...', NULL, NULL, Array)
#3 /usr/share/php/Zend/Gdata/App.php(983): Zend_Gdata_Gapps->post(Object(Zend_Gdata_Gapps_EmailListRecipientEntry), 'https://apps-ap...', NULL, NULL, Array)
#4 /usr/share/php/Zend/Gdata/Gapps.php(840): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_Gapps_EmailListRecipientEntry), 'https://apps-ap...', 'Zend_Gdata_Gapp...')
#5 /usr/share/php/Zend/Gdata/Gapps.php(1625): Zend_G in /usr/share/php/Zend/Gdata/App.php on line 716
Can anyone tell me what happened? And what I need to do to get this working again?
Thanks,
B
Google completely remove support for emaillists. Use groups instead lists.
Example:
instead $gdata->addRecipientToEmailList($email, $email_list)
use $gdata->addMemberToGroup($email, $group_name)
deleteEmailList -> deleteGroup
createEmailList -> createGroup
getEmailListRecipientFeed -> retrieveAllMembers
See full syntax in Zend docs:
http://framework.zend.com/manual/1.12/en/zend.gdata.gapps.html