I have problem with start Solarium Client, I downloaded it by Composer and GitHub according the wiki tutorial, it's ok, but I don't know what I must do now.
When I tried this example code:
<?php
require(__DIR__.'/init.php');
htmlHeader();
// check solarium version available
echo 'Solarium library version: ' . Solarium\Client::VERSION . ' - ';
// create a client instance
$client = new Solarium\Client($config);
// create a ping query
$ping = $client->createPing();
// execute the ping query
try {
$result = $client->ping($ping);
echo 'Ping query successful';
echo '<br/><pre>';
var_dump($result->getData());
echo '</pre>';
} catch (Solarium\Exception $e) {
echo 'Ping query failed';
}
htmlFooter();
I have the following error:
Warning: require(C:\xampp\htdocs\solarium/init.php): failed to open stream: No such file or directory in C:\xampp\htdocs\solarium\test.php on line 3
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\solarium/init.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\solarium\test.php on line 3
I use Xampp server.
Must I set some Path, where appropriate, how and where? File init.php is in folder: C:\xampp\htdocs\solarium\vendor\solarium\solarium\examples\ and i start the demo file in folder: C:\xampp\htdocs\solarium\
Sorry for my English. Thank you for help.
You have to run solarium examples, and examples derived form them like your test.php file, from the /examples directory in the solarium directory tree.
In this directory there is init.php file which is setting up 'display_errors' init variable, loading composer created autoload.php, loading the config.php and defining htmlHeader() and htmlFooter() functions.
Related
I have created the composer.json file in my root folder where my index.php file is presents, with the following code in it:
{
"require": {
"microsoft/windowsazure": "^0.5"
}
}
and on downloading composer.phar, I have installed it using:
php composer.phar install
I'm trying to create a table and add entities to it in php. I use the command
use WindowsAzure\Common\ServicesBuilder;
$connectionString = 'DefaultEndpointsProtocol=https;AccountName=******;AccountKey=***/***************************/******************/**********************************==';
$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
try {
// Create table.
$tableRestProxy->createTable("mytable");
}
catch(ServiceException $e){
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
When I run this on local host on my Ubuntu, I get an error saying-
Uncaught Error: Class 'WindowsAzure\Common\ServicesBuilder' not found in /home/my_folder/php-docs-hello-world-master/index.php:30
If I add
require_once 'vendor/autoload.php';
before defining my $connectionString, then my error changes to:
/index.php - Uncaught RuntimeException: Error creating resource: [message] fopen(https://eyesav.table.core.windows.net/Tables): failed to open stream: Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?
Can someone help me figure out this issue, if it is with the installation of my composer, or my connectionString, or something else?
Thanks in advance :)
Can someone help me figure out this issue, if it is with the installation of my composer, or my connectionString, or something else?
If I use the code you mentioned, I also could reproduce the issue you mentioned.
Please have a try to use following code to create the table client. It works for me.
use MicrosoftAzure\Storage\Table\TableRestProxy;
use MicrosoftAzure\Storage\Common\ServiceException;
$tableClient = TableRestProxy::createTableService($connectionString);
The following is the demo code from azure official document.
<?php
require_once "vendor/autoload.php";
use MicrosoftAzure\Storage\Table\TableRestProxy;
use MicrosoftAzure\Storage\Common\ServiceException;
$connectionString = 'DefaultEndpointsProtocol=https;AccountName=xxxx;AccountKey=xxxxxxx;';
$tableClient = TableRestProxy::createTableService($connectionString);
try {
$tableClient->createTable("mytable");
}
catch(ServiceException $e){
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}
I'm trying to create a single-file version of PHP framework Nette 2.4. I create a phar file using this code:
<?php
$phar = new Phar('nette.phar');
$phar->buildFromDirectory(__DIR__ . '/../vendor/nette');
$phar->setStub("<?php
require 'phar://' . __FILE__ . '/loader.php';
__HALT_COMPILER();");
$phar->compressFiles(Phar::GZ);
Everything is fine, the file is created. If I try to use this compacted version:
// bootstrap.php
<?php
require __DIR__ . '/nette.phar';
...
Error occurs:
Warning: require(phar://C:\wamp64\www\app\nette.phar/loader.php): failed to open stream: phar error: "loader.php" is not a file in phar "C:/wamp64/www/app/nette.phar" in C:\wamp64\www\app\nette.phar on line 2
So, single-file version is loaded, but there is no boot file loader.php. Does anyone know where is the mistake? Thanks for all the suggestions!
You can't create .phar from Nette downloaded via Composer. It doesn't have some necessary files (e.g. your Loader.php).
If you want to create .phar download official .zip from https://nette.org/en/download and create .phar from folder ./Nette.
__
BTW you don't need to create .phar yourself, you can find it in the .zip file in folder Nette-minified
I have an error that happens only on my host server, on my local environment not:
Fatal error: require_once() [function.require]: Failed opening required '\Audero\Loader\AutoLoader.php' (include_path='.:/usr/share/pear:/usr/share/php:/home/httpd/vhosts/webox-it.com/ofrom.webox-it.com/modules/Concordancier....\lib') in /home/httpd/vhosts/webox-it.com/ofrom.webox-it.com/modules/Concordancier/data_manager.php on line 1670
Here is my code:
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/../../lib/');
require_once 'Audero\Loader\AutoLoader.php';
spl_autoload_register('Audero\Loader\AutoLoader::autoload');
// Extract the chunk and save it on the hard disk
try {
$extractor = new \Audero\WavExtractor\AuderoWavExtractor($inputFile);
$extractor->saveChunk($start, $end, $outputFile);
...
Files structure:
/lib/Audero/Loader/Autoloader.php
Calling file emplacement:
/modules/Concordancier/data_manager.php
In my local environment there's no problem, php can load the autoloader, but in the prod server it does not.
The source files structure is exactly the same as the local one, and the relative path looks correct. The php version in prod is 5.3.27 so it should work ?
Any idea ?
I am trying to get crontab to run a php file, here is the cronjob
10 * * * * /usr/bin/php /var/www/update/ranks.php >> /var/www/update/log/ranks.txt
But I keep getting an error saying the required file does not exist
PHP Warning: require_once(../mws_products.php): failed to open stream: No such file or directory in /var/www/update/ranks.php on line 2
PHP Fatal error: require_once(): Failed opening required '../mws_products.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/update/ranks.php on line 2
I do not get this problem when I run the file from a browser or when I go into the directory of the file and execute the file e.g. cd /var/www/update/
ranks.php
<?php
require_once('../mws_products.php');
echo "-------------------------------------------------------------\n";
echo date('d-M-Y H:i:s',time())."\n";
echo "Update Ranks\n";
$products->updateRanks();
$database->addUpdate("ranks", time());
echo "\n\n\n";
?>
folder structure
[folder] update
|____ [file] ranks.php
[file] mws_products.php
What could be causing this problem? (note: I have tried restarting apache and the server)
As your are running in a crontab from the root directory ../mws_pruducts.php does not exists, relative to the given root.
There are multiple solutions, this is one of them:
define( 'ROOT', dirname(__FILE__) );
require_once(ROOT . '/../mws_products.php');
Try with the absolute path for the file...
require_once('/var/www/mws_products.php');
SOLVED, read bottom of post:
I'm trying to install the Sparks package manager on windows by following the official instructions.
Issuing this command:
php -r "$(curl -fsSL http://getsparks.org/go-sparks)"
results in this errormessage:
Parse error: syntax error, unexpected ':' in Command line code on line 1
If I only execute the curl command within the above line, i.e this:
curl -fsSL http://getsparks.org/go-sparks
it echoes out the php script located on the URL. So I think the problem is piping the curl output to PHP somehow fails. I've tried a couple of variants, using diffrent quotes etc but I'm at a loss.
MY SOLUTION
As DaveRandom pointed out, the instruction didn't apply to windows.
But instead of doing it the manual(normal) way, what I did was taking the output from curl, appending php script tags and executing it as a file with the php -f option.
Here is the output:
<?php
$zip = "http://getsparks.org/static/install/spark-manager-0.0.7.zip";
$loader = "http://getsparks.org/static/install/MY_Loader.php.txt";
if(!file_exists("application/core"))
{
echo "Can't find application/core. Currently this script only works with the default instance of Reactor. You may need to try a manual installation..\n";
exit;
}
echo "Pulling down spark manager from $zip ...\n";
copy($zip, "sparks.zip");
echo "Pulling down Loader class core extension from $loader ...\n";
copy($loader, "application/core/MY_Loader.php");
echo "Extracting zip package ...\n";
if(class_exists('ZipArchive'))
{
$zip = new ZipArchive;
if ($zip->open('sparks.zip') === TRUE)
{
$zip->extractTo('./tools');
$zip->close();
} else {
echo "Extraction failed .. exiting.\n";
exit;
}
} elseif(!!#`unzip`) {
`unzip sparks.zip -d ./tools`;
} else
{
echo "It seems you have no PHP zip library or `unzip` in your path. Use the manual installation.\n";
exit;
}
echo "Cleaning up ...\n";
#unlink('sparks.zip');
echo "Spark Manager has been installed successfully!\n";
echo "Try: `php tools/spark help`\n";
The instructions you linked do explicitly state;
In order to use this quick start option, you should be using OSX or some flavor of linux.
You need to follow the Normal Installation instructions for use on Windows.
You should execute the command php -r "$(curl -fsSL http://getsparks.org/go-sparks)" in your root application folder. Maybe you're executing this command at wrong folder.