Programmatically get Turpentine to apply VCL to Varnish from the commandline - ansible

I'm deploying a server using Ansible. I would like to get Turpentine to apply VCL from the command line so that when I first visit the new server it's already using the correctly compiled VCL for that environment.

Run a command like php ~/applyvcl.php
and in the php file:
<?php
require_once '/path/to/magento/app/Mage.php';
Mage::app('admin');
$res = Nexcessnet_Turpentine_Model_Varnish_Admin::applyConfig();
var_dump($res);
?>
You should see success message from that.

Related

Installing and using Mink with Browserkit driver

I seem to be unable to install Mink with Browserkit driver on Centos.
I am using these instructions: https://github.com/minkphp/MinkBrowserKitDriver
The steps I am taking is by:
adding a file in my project directory with the name composer.json and the contents:
{
"require": {
"behat/mink": "~1.5",
"behat/mink-browserkit-driver": "~1.1"
}
}
Use the commands as below.
$> curl -sS https://getcomposer.org/installer | php
$> php composer.phar install
Now there are 3 files (composer.json, composer.lock, composer.phar) and one folder (vendor) in the project directory. Where do I run the "Usage example" code from (as on the documentation)?
I have tried adding require_once "vendor/autoload.php"; to my test.php file:
<?php
require_once "vendor/autoload.php";
use Behat\Mink\Mink,
Behat\Mink\Session,
Behat\Mink\Driver\BrowserKitDriver;
use Symfony\Component\HttpKernel\Client;
$app = require_once(__DIR__.'/app.php'); // Silex app
$mink = new Mink(array(
'silex' => new Session(new BrowserKitDriver(new Client($app))),
));
$mink->getSession('silex')->getPage()->findLink('Chat')->click();
but getting a fatal error that app.php cannot be opened. I have also tried adding the following to test.php:
require_once 'vendor/behat/mink-browserkit-driver/tests/app.php';
Any help would be appreciated :)
Its seems you're missing some guideline in order to organize your code. Before integrating Behat and Mink, first of all you should organize your Silex project. My advice is for you to take a look at the official Silex Skeleton project.
After that you can start by installing behat, mink and your driver:
cd path/to/your/silex/project/root
composer require behat/behat:~2.5 behat/mink behat/mink-browserkit-driver
Then you can initialize behat.
bin/behat --init
Then configure your mink driver in behat.yml (on your project root directory)
default:
extensions:
Behat\MinkExtension\Extension:
browserkit: ~
base_url: http://my.dev.host
Notice that browser kit cannot execute JS, remember that (if you want to execute JS on your tests, you should install another driver)
After that you can start writing your features on the features directory (behat should've created that for you), for example if you have this controller in src/controllers.php:
<?php
//...
$app->get('/hello', function () use ($app) {
return new Response("Hello world!");
});
You can write the feature (on features/greeting.feature):
Feature: Greetings from /hello page
In order to say hello world
As a visitor
I need to go to the /hello page and see Hello world!
Scenario: See Hello world!
Given I am on "/hello"
Then I should see "Hello world!"
Another option is to use full behat extension for silex: https://github.com/tabbi89/Behat-Silex-Extension
You can check how integrations of Mink and browserKit work there.

Magento Command line script Class 'SoapClient' not found

I am trying to run a script from commandline to call a method in a Model, which involves the class SoapClient But come up with the error message
PHP Fatal error: Class 'SoapClient' not found in ....
Line which has the error is
$client = new SoapClient($this->_soapUrl);
I run the same process through web using a test route and it works.
Checked PHPINFO and it says
Soap Client enabled
Soap Server enabled
How can I include the SoapClient Class to the script or what can be the solution?
Your command line PHP uses different php.ini. Find out which php.ini file is used in PHP CLI and make sure the Soap extension is loaded there as well.

codeigniter on wamp 403 forbidden error

I set up a codeigniter project on my wamp www folder
The assets of my project is in 'assets' folder which is in the same folder as the application folder.
However when I access my localhost, the css,images and js which are in the asset folder is unable to load.
When I type localhost/assets instead, I can access them.
I set http.conf in the apache folder to set to "Allow from all" as well.
when i access the url from the developer tools for chrome, I have characters within the url like this
%3C?=%20base_url()%20?%3Eassets/img/a.jpg
Any idea what is wrong here?
It seams that the function base_url() is not executed and just printed in your view.
Try to enclose the function in a php block and echo it out with the path to the asset.
<?php
echo base_url() . 'assets/img/a.jpg';
?>
Or as stealthyninja mentioned in the comment, the short-open-tag you used is interpreted as text.
You can enable it in the php.ini with
short_open_tag=On
When you can't modify the php.ini, you can enable it in the codeigniter config.php with
$config['rewrite_short_tags'] = TRUE;
Now the short open tags are interpreted right
<?= base_url() . 'assets/img/a.jpg' ?>
check you config.php file:
$config['rewrite_short_tags'] = TRUE;
or try this :
<?php echo base_url()?>assets/img/a.jpg

Joomla include js using jumi

I can't manage to include a javascript in an article(directly in the wysiwyg editor) using jumi.
What I've tried:
{jumi /path/to/file.js}
{jumi [/path/to/file.js]}
{jumi /path/to/file.js}{/jumi}
{jumi [/path/to/file.js]}{/jumi}
"file.js" is located in a folder in the same directory as Joomla.
I'm using joomla v. 1.7.3 and Jumi 2.0.6.
Is there something I'm missing?
I'm not sure if this solution is much different than yours, but you can got to the Jumi Application Manager and create a new entry like this:
<?php
$document =& JFactory::getDocument();
$document->addStyleSheet('path/file.css');
$document->addScript('path/file.js');
?>
Then add this to your article:
{jumi[*5]}
Where "5" is the id of the Jumi entry.
At least this is how I do it in Joomla 1.5...
I've found a workaround, it's not elegant, but it works:
create two files, 1 php which will echo a script element and a javascript file that you wish to include
in the article put:
{jumi [path/to/a/php/file.php]}
the php file should be
<?php
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"path/to/js/file.js\"></script>"
?>
Enjoy!

syntax error at server for the code works fine at localhost... it is weird! :/

I have an interesting issue :/ I use CodeIgniter and the code below is working fine at my localhost, but when I upload to server I come cross with an error message like
Parse error: syntax error, unexpected
T_OBJECT_OPERATOR in
/home3/blabla/public_html/blablabla/applications/frontend/models/our_work_model.php
on line 99
function next_project($sort_work)
{
$query = $this->db->select('wname')->order_by('sort', 'asc')->getwhere('works', array('sort >' => $sort_work, 'case_study != ' => ""), 1, 0); //line 99
any idea? appreciate helps! thanks!
I know chaining like that only works in PHP5 - is the server perhaps running an older version of PHP?
Given your last question: __construct() { issue for PHP4 and PHP5. maybe an another reason
I'd say you're running PHP4.
How do you know that your CodeIgniter installation is actually using PHP 5? It could be the case that there are several PHP installations in that machine. To test it, create a PHP file in your server with the following code:
<?php
phpinfo();
?>
Then let us know what version it is showing.
initially i was getting a blank page. so i removed this
error_reporting((E_ALL & ~E_DEPRECATED));
yes if you are using codeigniter and you have to make ove code to this
error_reporting((E_ALL));
and then you will get the error above. and i found it was due to php5 being unused.

Resources