PhpUnit : Error: Unable to access jarfile ./../src/Java/File.jar - symfony

When I run the test of my page, I encounter this error message that I do not have on the browser:
Error: Unable to access jarfile ./../src/Java/File.jar
Here is the call to the file in my controller (symfony 4):
exec("java -jar ./../src/Java/File.jar $params",$tab);
Here is my test method :
public function testView(){
$crawler = $this->client->request('GET','/test/1');
if( Response::HTTP_OK !== $this->client->getResponse()->getStatusCode()){
echo $crawler->filter('div.exception-message-wrapper')->text();
echo $crawler->filter('.trace-html-1')->text();
}
static::assertEquals(
Response::HTTP_OK,
$this->client->getResponse()->getStatusCode()
);
}
thanks for your help

In your controller you could try using a path to the jar which will be relative to the __DIR__.
exec("java -jar " . __DIR__ . "../src/Java/File.jar $params", $tab);
To understand, you can read more about __DIR__ here

Related

symfony2 twig FileException: Unable to create the "/voice_mails" directory

$r = $app['request'];
foreach ($r->files as $uploadedFile) {
$name = basename($_FILES["wavFile"]["name"]);
$file = $uploadedFile->move('/voice_mails', $name);
print_r($file);
}
I am trying to upload file using above code , But throwing error like:
FileException: Unable to create the "/voice_mails" directory
Please Help me.
console
mkdir your_path/voice_mails
chmod -R 777 your_path/voice_mails
chown -Rf apache:apache your_path/voice_mails
And check fisical path /var/www/yourproject or use dirname()
FileException is thrown because you're trying to create voice_mails directory in root folder /. You want to create in in your web root folder, so you code should be like:
foreach ($r->files as $uploadedFile) {
//…
$file = $uploadedFile->move($this->get('kernel')->getRootDir() . '/../web/voice_mails', $name);
//…
}

Wordpress : Genesis-Legacy Theme error

I am getting this error message on some of my pages within worrdpress dashboard.
Google Analytics Stats
Warning: array_merge(): Argument #1 is not an array in
/home/c5280den/public_html/wp-content/plugins/google-analyticator/google-api-php-client/src/Google_Client.php
on line 40
Fatal error: Class name must be a valid object or a string in
/home/c5280den/public_html/wp-content/plugins/google-analyticator/google-api-php-client/src/Google_Client.php
on line 104
Any help is most appreciated!!
Update your plugin bro.. If updated already, try this.
FILE - google-analyticator > google-api-php-client > src > Google_Client.php
OLD CODE (starting at Line 35)
require_once "config.php";
// If a local configuration file is found, merge it's values with the default configuration
if (file_exists(dirname(__FILE__) . '/local_config.php')) {
$defaultConfig = $apiConfig;
require_once (dirname(__FILE__) . '/local_config.php');
$apiConfig = array_merge($defaultConfig, $apiConfig);
NEW CODE (starting at Line 35)
require_once (dirname(__FILE__) . "/config.php");
// If a local configuration file is found, merge it's values with the default configuration
if (file_exists(dirname(__FILE__) . '/local_config.php')) {
$defaultConfig = $apiConfig;
require_once (dirname(__FILE__) . '/local_config.php');
$apiConfig = array_merge($defaultConfig, $apiConfig);
Adding to line 35...
require_once (dirname(__FILE__) . "/config.php");
in place of...
require_once "config.php";
seems to have fixed the problem.
Get it from here https://wordpress.org/support/topic/recent-update-throws-error-in-settings-page

How to fix gearman PHP Warning: GearmanClient::do(): _client_do(GEARMAN_TIMEOUT) occured during gearman_client_run_tasks() on Ubuntu 12.04

Getting an error PHP Warning: GearmanClient::do(): _client_do(GEARMAN_TIMEOUT) occured during gearman_client_run_tasks() while running client script.
//------------worker.php
#!/usr/bin/php -q
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction( "test" , "test_function" );
while ($worker->work());
function test_function( $job )
{
return strtoupper($job->workload());
}
?>
//------------client.php
<?php
$client = new GearmanClient();
$client->addServer();
$client->setTimeout(1000);
print "\n";
print $client->do( "test" , "this is a test" );
die();
?>
Use nohub posix command to run the worker in the background
run worker using below command
nohup /usr/bin/php worker.php > /dev/null 2>&1 &
run client using below command
php client.php

Symfony 2.2.1 rsync deploy - not working on remote server

I'm very new to Symfony and I'm trying to automate the deploy process with rsync, while keeping both the local and remote installs of Symfony working.
What I've done so far:
installed Cygwin on my local machine (Windows 7+Apache2.2+PHP 5.3+MySQL 5.1)
done a basic Symfony install on my local machine from shell with the command
php composer.phar create-project symfony/framework-standard-edition [path]/ 2.2.1
set up a remote LAMP Ubuntu server with php-fpm (fastcgi)
set up two different configuration files for local and remote in the app/config/ dir, parameters.yml and parameters.yml.remote
created an app/config/rsync_exclude.txt file containing a list of files not to rsync to the remote server (as suggested in this page)
created a deploy shell script that I run from Cygwin (see below)
The deploy script issues the commands:
rsync -avz /cygdrive/c/[path]/ user#server:[remote-path]/ --exclude-from=/cygdrive/c/[path]/app/config/rsync_exclude.txt
ssh user#server 'cd [remote-path]/ && php app/console --env=prod cache:clear && php app/console cache:clear'
ssh user#server 'mv [remote-path]/app/config/parameters.yml.remote ~/[remote-path]/app/config/parameters.yml'
The rsync, ssh and mv commands work, but the deployed site shows always a HTTP 500 error (both app.php and app_dev.php).
Looking at server error log the error is:
Fatal error: Class 'Composer\\Autoload\\ClassLoader' not found in /[remote-path]/vendor/composer/autoload_real.php on line 23
Any clue would be more than welcome.
Edit - here is my vendor/composer/autoload_real.php file (sorry for the making the question longer!):
<?php
// autoload_real.php generated by Composer
class ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
// ^^^^^^ this is line 23 and gives the error ^^^^^^^^^^^
spl_autoload_unregister(array('ComposerAutoloaderInit9d50f07556e53717271b583e52c7de25', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->add($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register(true);
require $vendorDir . '/kriswallsmith/assetic/src/functions.php';
require $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php';
return $loader;
}
}
If there is an error with the autoloader generated by composer, performing ...
composer update
... will update your dependencies and create a new one.
You should invoke the command with the -o flag if you are deploying to a production system.
This way composer generates a classmap autoloader ( which performs way better ) instead of the classic autoloader.
composer update -o
I guess re-generating the autoloader will solve the issue :)

symfony 2.1: phpunit -c app tries to run symfony core tests

In my Symfony 2.1 app, I'm unable to run the recommended phpunit -c app/. I get the following error message (I added linebreaks):
PHPUnit 3.6.10 by Sebastian Bergmann.
Configuration read from /symfony2-dual-auth/app/phpunit.xml.dist
F
PHP Fatal error: main(): Failed opening required
'/symfony2-dual-auth/vendor/symfony/symfony/vendor/autoload.php'
(include_path='.:/usr/share/php:/usr/share/pear')
in /symfony2-dual-auth/vendor/symfony/symfony/autoload.php.dist on line 3
Complete source code here: https://github.com/meonkeys/symfony2-dual-auth . Except the test, since it doesn't pass. Here's src/Oh/FOSFacebookUserBundle/Tests/SimpleFunctionalTest.php...
<?php
namespace Oh\FOSFacebookUserBundle\Tests;
use Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase;
class SimpleFunctionTest extends WebTestCase {
public function testIndex() {
$client = static::createClient();
$crawler = $client->request('GET', '/login');
$this->assertEquals(1, $crawler->filter('html:contains("Remember me")')->count());
}
}
I was extending the wong class. Here's the fix:
-use Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase;
+use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

Resources