Kohana Undefined property: Request::$action - php

I'm trying to set up my first Kohana web page, using this tutorial - http://kohana-tutorial.blogspot.co.uk/2010/10/lesson-1-getting-started.html
After following the instructions, I am left with this error - Undefined property: Request::$action on line 49.
This is the code related to that line, in DefaultTemplate.php
48 if (!$view){
49 $view = 'pages/'.$this->request->controller().'/'.$this->request->action.'_tpl';
50 }
51 $this->template->content = View::factory($view, $this->data);
52 }
53 }
54 ?>
This is called by News.php, which is a standard call to render something.
class Controller_News extends Controller_DefaultTemplate {
public function __construct(\Request $request, \Response $response) {
parent::__construct($request, $response);
}
public function action_index(){
$this->render();
}
}
The complete list of programs used to get to this error is :
APPPATH/classes/Controller/DefaultTemplate.php [ 49 ] » Kohana_Core::error_handler(arguments)
APPPATH/classes/Controller/News.php [ 13 ] » Controller_DefaultTemplate->render()
SYSPATH/classes/Kohana/Controller.php [ 84 ] » Controller_News->action_index()
{PHP internal call} » Kohana_Controller->execute()
SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments)
SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal- >execute_request(arguments)
SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments)
DOCROOT/index.php [ 118 ] » Kohana_Request->execute()APPPATH/classes/Controller/News.php [ 13 ] » Controller_DefaultTemplate->render()
SYSPATH/classes/Kohana/Controller.php [ 84 ] » Controller_News->action_index()
{PHP internal call} » Kohana_Controller->execute()
SYSPATH/classes/Kohana/Request/Client/Internal.php [ 97 ] » ReflectionMethod->invoke(arguments)
SYSPATH/classes/Kohana/Request/Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments)
SYSPATH/classes/Kohana/Request.php [ 997 ] » Kohana_Request_Client->execute(arguments)
DOCROOT/index.php [ 118 ] » Kohana_Request->execute()
Any help would be gratefully recieved.

This tutorial is 4 years old, so it is probably a little outdated.
With current version of Kohana, You can access to the protected property $request->_action with the following:
$this->request->action();
Don't hesitate to check the online documentation or even the source code in system/classes/Kohana, which is clear and well commented.

Related

Wkhtmltopdf Gives An uncaught Exception

I am trying to wkhtmltopdf for download my data to pdf getting an errors below.
Any help would be really appreciated.
An uncaught Exception was encountered
Type: Exception
Message: System error
Loading pages (1/6)
[> ] 0%
[======> ] 10%
[=======> ] 12%
Warning: SSL error ignored
[========> ] 14%
[=========> ] 16%
[==========> ] 18%
[============> ] 20%
[=============> ] 23%
[===============> ] 25%
[================> ] 27%
[=================> ] 29%
[==================> ] 31%
[===================> ] 33%
[=====================> ] 35%
[======================> ] 38%
[========================> ] 40%
[=========================> ] 43%
[===========================> ] 45%
[============================> ] 47%
[=============================> ] 49%
[=====================================> ] 63%
[==========================================> ] 70%
[=============================================> ] 76%
[=================================================> ] 83%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[==============================> ] Page 1 of 2
[============================================================] Page 2 of 2
Done
Filename: application/libraries/Wkhtmltopdf.php
Line Number: 866
Backtrace:
File: /var/www/admin/index.php
Line: 315
Function: require_once
Here's the line from my PHP codeigniter file that's sending the error in case that helps:
$html = $this->load->view('report/view_course_summary_pdf', $data, true);
$pdfFilePath = "Course_Summary_Report.pdf";
$options['path'] = $myPath;
$options['orientation'] = 'Landscape';
$options['commandOptions'] =
array(
'useExec' => true, // Can help if generation fails without a useful error message
'procEnv' => array(
// Check the output of 'locale' on your system to find supported languages
'LANG' => "'" . $this->session->userdata('lang_code') . "_US.utf-8" . "'",
)
);
$this->load->library('wkhtmltopdf', $options);
$this->wkhtmltopdf->setTitle($this->common_lang->get_lang_token('course_summary_report'));
$this->wkhtmltopdf->setOptions(['ignoreWarnings' => true]);
$this->wkhtmltopdf->setHtml($html); // $html can be a url or html content.
$this->wkhtmltopdf->output(Wkhtmltopdf::MODE_DOWNLOAD, $pdfFilePath);
A bunch of people have talked about similar issues that are related to using WKPDF with an SSL, but I don't think that's causing my problems since it says the SSL error was ignored... Any help would be really appreciated. Whenever I try doing it, there my HTML is download but it corrupted format using above Codeginter code.

How to set up a Mapping while indexing data through bulk API in Elasticsearch-PHP?

I am trying to follow this tutorial, and I need to do it in PHP, so I have to use Elasticsearch-php. In this particular step, I am trying to set up a mapping for elasticsearch and also bulk index data from a .json file. So I looked into examples here and [here][3], and following is my code.
The problem is taht it gives me
Elasticsearch PHP client created successfully!
Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [dynamic]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [dynamic]"},"status":400} in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:610 Stack trace: #0 /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(273): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/Tests/Test/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) #2 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL) #3 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/ in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 610
and when I comment out the line "dynamic" => "false", I get
Elasticsearch PHP client created successfully!
Fatal error: Uncaught Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected a simple value for field [properties] but found [START_OBJECT]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected a simple value for field [properties] but found [START_OBJECT]"},"status":400} in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:610 Stack trace: #0 /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(273): Elasticsearch\Connections\Connection->process4xxError(Array, Array, Array) #1 /var/www/html/Tests/Test/vendor/react/promise/src/FulfilledPromise.php(25): Elasticsearch\Connections\Connection->Elasticsearch\Connections\{closure}(Array) #2 /var/www/html/Tests/Test/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(O in /var/www/html/Tests/Test/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php on line 610
What am I missing? How should I fix this?
<?php
require_once("vendor/autoload.php");
use Elasticsearch\ClientBuilder;
$esClient = ClientBuilder::create()->build();
echo "Elasticsearch PHP client created successfully!<br>";//check
$indexParams = array();
$indexParams['index'] = "test_packets_index";
$indexParams['type'] = "testPacketsType";
$indexParams['body'] = [
'mappings' => [
"testPacketsType" => [
//"dynamic" => "false",
"properties" => [
"timestamp" => [
"type" => "date"
],
"layers" => [
"properties" => [
"ip" => [
"properties" => [
"ip_ip_src" => [
"type" => "ip"
],
"ip_ip_dst" => [
"type" => "ip"
]
]
]
]
]
]
]
]
];
$jsonFileHandle = fopen("packets.json", "r");
if ($jsonFileHandle) {
while ( ($line = fgets($jsonFileHandle)) !== FALSE ) {
if ( !($line == "") ) {
$indexParams['body'][] = json_decode($line, true);
}
}
}
fclose($jsonFileHandle);
#print_r($indexParams['body']);//check
$indexingResponse = $esClient->bulk($indexParams);
echo "Result: "; print_r($indexingResponse); echo "<br>";//check
?>
[3]: https : //www.elastic.co/guide/en/elasticsearch/client/php-api/current/_indexing_documents.html

Facade error in laravel 5.2

I installed a package in Laravel 5.2 named jonnywilliamson/laragram
And put in config\app.php a alias and service provider like below :
'providers' => [
.
.
.,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Williamson\Laragram\Laravel\LaragramServiceProvider::class,
]
'aliases' => [
.
.
.,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'TG' => Williamson\Laragram\Laravel\LaragramFacade::class,
]
And in my contoller :
use TG;
public function test()
{
return TG::sendMsg('+989118000000', 'Hello there!');
}
And route:
Route::get('test', 'Services\Auth\Controller\v1_0\AuthController#test');
I also run the following commands :
composer dumpautoload
composer dumpautoload -o
php artisan cache:clear
php artisan clear-compiled
php artisan optimize
But still shows error like:
RuntimeException in Facade.php line 210:
A facade root has not been set.
in Facade.php line 210
at Facade::__callStatic('sendMsg', array('+989118000217', 'Hello there!')) in User.php line 68
at LaragramFacade::sendMsg('+989118000217', 'Hello there!') in User.php line 68
at AuthController->test('fa')
at call_user_func_array(array(object(AuthController), 'test'), array('lang' => 'fa')) in Controller.php line 80
at Controller->callAction('test', array('lang' => 'fa')) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(AuthController), object(Route), 'test') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
How can i fix it?
The function you are trying to call is called sendMessage:
return TG::sendMessage('+989118000000', 'Hello there!');
You are using sendMsg, which is causing the error.

Kohana3 Function name must be a string exception in Route class

I have the following code in Welcome_Controller action_index method:
$route = new Route('(<controller>(/<action>(/<id>)))');
$body = $route->uri(array(
'controller' => 'welcome',
'action' => 'index',
'id' => '10'
));
echo Debug::vars($body);
When $route->uri method is called, I am getting an error:
ErrorException [ Fatal Error ]: Function name must be a string in SYSPATH/classes/Kohana/Route.php [ 589 ]
584 }
585
586 return array($result, $required);
587 };
588
589 list($uri) = $compile($this->_uri, TRUE);
590
591 // Trim all extra slashes from the URI
592 $uri = preg_replace('#//+#', '/', rtrim($uri, '/'));
593
594 if ($this->is_external())
Why am I getting this error? According to Kohana install.php file, my environment passed all requirements.
$compile is an anonymous function, but according to PHP Manual there were introduced in PHP 5.3.0 version, which I have on my hosting environment. Maybe there is an option to enable/disable anonymous functions in PHP?
You can find whole code here: https://github.com/DamianKedzior/kohana/tree/3.3/route_uri_exception

Adding extension in Debug mode getting : "chmod(): operation not permitted"

When am adding an extension (EfontAwesome, ref: www.yiiframework.com/extension/efontawesome) to Yii I am getting "chmod(): operation not permitted"
The Call Stack looked something like this..
/opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(133)
121 while(($file=readdir($folder))!==false)
122 {
123 if($file==='.' || $file==='..')
124 continue;
125 $path=$src.DIRECTORY_SEPARATOR.$file;
126 $isFile=is_file($path);
127 if(self::validatePath($base,$file,$isFile,$fileTypes,$exclude))
128 {
129 if($isFile)
130 {
131 copy($path,$dst.DIRECTORY_SEPARATOR.$file);
132 if(isset($options['newFileMode']))
133 chmod($dst.DIRECTORY_SEPARATOR.$file,$options['newFileMode']);
134 }
135 elseif($level)
136 self::copyDirectoryRecursive($path,$dst.DIRECTORY_SEPARATOR.$file,$base.'/'.$file,$fileTypes,$exclude,$level-1,$options);
137 }
138 }
139 closedir($folder);
140 }
141
142 /**
143 * Returns the files found under the specified directory and subdirectories.
144 * This method is mainly used by {#link findFiles}.
145 * #param string $dir the source directory
Stack Trace
#0
+ /opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(133): chmod("/opt/lampp/htdocs/im/assets/6950b6ca/css/font-awesome.css", 438)
#1
+ /opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(136): CFileHelper::copyDirectoryRecursive("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets/cs...", "/opt/lampp/htdocs/im/assets/6950b6ca/css", "/css", array(), ...)
#2
+ /opt/lampp/htdocs/yii-1.1.13/framework/utils/CFileHelper.php(63): CFileHelper::copyDirectoryRecursive("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets", "/opt/lampp/htdocs/im/assets/6950b6ca", "", array(), ...)
#3
+ /opt/lampp/htdocs/yii-1.1.13/framework/web/CAssetManager.php(251): CFileHelper::copyDirectory("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets", "/opt/lampp/htdocs/im/assets/6950b6ca", array("exclude" => array(".svn", ".gitignore"), "level" => -1, "newDirMode" => 511, "newFileMode" => 438))
#4
– /opt/lampp/htdocs/im/protected/extensions/EFontAwesome/components/EFontAwesome.php(41): CAssetManager->publish("/opt/lampp/htdocs/im/protected/extensions/EFontAwesome/assets", false, -1, true)
36 public function getAssetsUrl() {
37 if (isset($this->_assetsUrl))
38 return $this->_assetsUrl;
39 else {
40 $assetsPath = Yii::getPathOfAlias('efontawesome.assets');
41 $assetsUrl = Yii::app()->assetManager->publish($assetsPath, false, -1, YII_DEBUG);
42 return $this->_assetsUrl = $assetsUrl;
43 }
44 }
45 }
This is only happening in debug mode and not in production mode.
The directory is writable by the web process (as it can be seen to work in production mode) and this extension was working perfectly well in debug mode few days back,
A brief google search only bought up the this closed issue on github :https://github.com/yiisoft/yii/issues/1853 regarding forcedCopy and linkAssets config conflict, which was fixed in Yii-1.1.13(the version I am using), just to be safe I had also tried setting the config of both to false in the main config files like this
'assetManager' => array(
'linkAssets' => false,
'forceCopy'=>false,
),
but the issue is persisting, any ideas on how to solve this?

Categories