installing codeigniter sparks manager on windows - 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.

Related

How to run node module in php and display output?

I have a use case where i need to run a node module in php script and display it's output back on the page. Here's the steps I followed:
I have installed the module npm install -g md2gslides
I am using PHP's exec() for running the module
exec('node_modules/md2gslides/bin//md2gslides.js --version 2>&1', $output);
But it's not working. The error is below:
However, it runs in ubuntu's terminal without issues.
What is wrong here?
The error not because of php but because of the path.join() in line 33 of md2gslides.js
const STORED_CREDENTIALS_PATH = path.join(USER_HOME, '.md2googleslides', 'credentials.json');
It tries to find the credentials.json in users home directory. But I think it's unable to.
So I moved the file to node_modules/md2gslides/bin and modified path.join() as path.join(__dirname, '.md2googleslides', 'credentials.json')
This solved the issue.

Run mjml cli using symfony process

I've installed mjml cli using the following command (as described in the mjml documentation):
npm install mjml --save
now if i did node_modules/.bin/mjml in the command line it will run successfully.
the problem is when i use the symfony process component in php i got the following error (even if it's the right path):
The command "/Users/qoraiche/Documents/my-app/node_modules/.bin/mjml" failed. Exit Code: 127(Command not found) Working directory: /Users/qoraicheOS/Documents/my-app/public Output: ================ Error Output: ================ env: node: No such file or directory
Symfony process code:
$process = new Process(base_path('node_modules/.bin/mjml'));
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
By the way i have installed mjml globally as well and try it with no luck.
Try providing the full path to node.js when calling the MJML binary from a Symfony Process().
$process = new Process('/your/path/to/node ' . base_path('node_modules/.bin/mjml'));
I use this method in my own apps. Of course, you will need to provide the input and output files to actually transpile anything.

phpredis errors Class Redis not found in Linux

I met a weied problem when installing phpredis by
cd phpredis && ./configure && make && make install
after that, I add
extension=redis.so
into php.ini.
I can get an OK by running
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
BUT when running http:127.0.0.1, nginx throw a error " Fatal error: Class 'Redis' not found in index.php"
<?php>
$client = new Redis();
<?>
I guess this may be some problems related with environment...
Thanks for any advice!
The command line probably does not use the same php.ini file than the web server.
Use phpinfo(); to know which configuration file is loaded in both cases and then declare your extension in the ini file used by your web server.
I had this issue minutes ago, and I solved it restarting the server, this way the server refresh *.ini files
If you're using composer and get the error "Class Redis not found" try put a backslash before the name class. Like this:
<?php
$client = new \Redis();
<?

shell_exec() not executing pdftotext command

I installed the required library and its working in terminal but not in my php file.
My code is :
$mypdf = shell_exec('/usr/local/bin/pdftotext test.pdf test.txt');
echo $mypdf;
If I execute this command /usr/local/bin/pdftotext test.pdf test.txt in terminal it works fine.
I also write my code this type :
shell_exec('/usr/local/bin/pdftotext test.pdf test.txt');
$mypdf = file_get_contents("test.txt");
echo $mypdf;
In Error Log the message is :
/usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)
My guess would be that you're expecting $mypdf to contain the PDF document instead of the return value of the executed command. If you're trying to print out 'test.txt', then you'll need to load it up and print it.
Issue was: /usr/local/bin/pdftotext: /opt/lampp/lib/libgcc_s.so.1: version 'GCC_4.2.0' not found (required by /usr/lib/i386-linux-gnu/libstdc++.so.6)
And the solution was to rename /opt/lampp/lib/libgcc_s.so.1 to libgcc_s.so.1.bak and solves my problem. But confusion is that what was the issue in it :P
I think you have some trouble with a dependency. Check your error.log. Find out which file is missing and add it to the path environment variable of your php installation.

php error: unexpected T_OBJECT_OPERATOR.... trying to install magento using ssh commands to dreamhost

I am trying to install magento (e-commerce platform)
I am following a tutorial that tells me to run this command using ssh: ./pear mage-setup
but I'm getting this error:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/domainname.com/downloader/pearlib/php/System.php on line 400
Line 400 is commented in the code snippit from the system.php file:
/* Magento fix for set tmp dir in config.ini
*/
if (class_exists('Maged_Controller',false)) {
/*line 400 */
$magedConfig = Maged_Controller::model('Config',true)->load();**
if ($magedConfig->get('use_custom_permissions_mode') == '1' &&
$mode = $magedConfig->get('mkdir_mode')) {
$result = System::mkDir(array('-m' . $mode, $tmpdir));
} else {
$result = System::mkDir(array('-p', $tmpdir));
}
if (!$result) {
return false;
}
}
Can anyone help me demystify this error?
I'm wondering what the double-stars are on the fifth line:
# here - v
$magedConfig = Maged_Controller::model('Config',true)->load();**
Edit: You are attempting to use "chaining" ($obj->func()->otherFunc()) which is only supported in PHP5:
$magedConfig = Maged_Controller::model('Config',true)->load();
Change the line to this:
$magedConfig = Maged_Controller::model('Config',true);
$magedConfig = $magedConfig->load();
Your other option is to upgrade to PHP 5, but at this point in the game, it might break your code.
Verify that you meet the following requirements:
http://www.magentocommerce.com/system-requirements
Magento only runs on php 5.2.x, not 5.3.
Also make sure the extensions listed on the requirements page are enabled.
Might be different for you, but I can check the php version using
php -v
Try ./mage mage-setup instead of ./pear mage-setup.
The following instruction solved this issue for me:-
Solution:
In the directory that your magento installation is in
nano pear
after the first two lines paste
MAGE_PEAR_PHP_BIN=/usr/local/bin/php5;
export MAGE_PEAR_PHP_BIN
ctrl + o -> to save
ctrl + x -> to exit
The above solution is about editing file named 'pear' present in your Magento root folder through terminal. If you have FTP access then you can simply edit the file 'pear' by adding the following lines at the beginning:-
MAGE_PEAR_PHP_BIN=/usr/local/bin/php5;
export MAGE_PEAR_PHP_BIN
Source: http://www.magentocommerce.com/boards/viewreply/222042/

Categories