I am making my own package.
I simplified the code to explain the weird error.
I have a simple method inside a simple controller. First, i am sending an email (printing in laravel.log) and works fine.
public function signup(){
Mail::send('vendor.proto.register.emails.proto-register-new-account', [], function ($m) {
$m->from('noreply#test.com', 'Hello');
$m->to('sfs#dgf.c', 'pepe')->subject('Test. Congratulations, your account was created');
});
return view('view path');
}
But when i want to move the Mail:: to a private method like this.
public function signup(){
$this->sendNotification2();
return view('view path');
}
public function sendNotification2(){
Mail::send('vendor.proto.register.emails.proto-register-new-account', [], function ($m) {
$m->from('noreply#test.com', 'Hello');
$m->to('sfs#dgf.c', 'pepe')->subject('Test. Congratulations, your account was created');
});
}
It crash an print the error
FatalErrorException in ClassLoader.php line 373: Maximum function nesting level of '100' reached, aborting!
Is it a bug? or i am doing something wrong ?
Solution.
Googling i found this solution. Notice i am using laravel 5.2 and php 5.6.7
Add in bootstrap\autoload.php this code ini_set('xdebug.max_nesting_level', 200); and it fix the problem.
Related
I'm new in Laravel and I'm trying to create a View in Acelle (app based on Laravel). I read a lot of tutorials, but I've not been luck with this problem.
I created the view "lol.blade.php" on /resources/views folder with this code:
HELLO (just hello)
The Route:
Route::get('lol', function()
{
if (view()->exists('lol')) {
//return 'helloooo'; <--- it works
return view('lol');
} else {
return 'not exists';
}
});
The code knows the view exists, but the url (localhost/acelle/public/lol) prints this message:
"Whoops, looks like something went wrong."
I can't solve the problem with tutorials. I followed all the steps about creating views in Laravel, but I don't know why the view prints that message.
Please help!
PS: Laravel version: 5.2.45
EDIT:
In console [network] shows Error 500. and laravel.log prints 59 lines. but the first line show:
[2017-07-14 14:08:20] production.ERROR: ErrorException: Undefined index:controller in /home/acelle/public_html/acelle/app/Providers/AppServiceProvider.php:20
You posted this in the comments:
app('view')->composer('*', function ($view) {
$action = app('request')->route()->getAction();
$controller = class_basename($action['controller']);
list($controller, $action) = explode('#', $controller);
$view->with(compact('controller', 'action'));
});
Your issue is that this route uses a closure, and has no controller:
Route::get('lol', function() {});
Therefore, $action['controller'] doesn't exist and throws a warning as a result. You'll want to check isset($action['controller']) before doing the rest of your code that uses the controller variable.
Already solved!!
SOLUTION:
creating a controller : MiwebController.php
<?
namespace Acelle\Http\Controllers;
class MiwebController extends Controller
{
public function __construct()
{
parent::__construct();
$this->middleware('auth');
}
public function index()
{
return view('lol');
}
}
?>
routes.php:
Route::get('lol', 'MiwebController#index');
It works fine. Thank you!
I'm currently working on some project on Symfony 2.8.
I've come across this weird PHP error.
I'm building a symfony command that allows using Kahlan test framework inside a Symfony project. Thus, I need the Symfony container to be available in Kahlan test suites, and so to be defined as global variable of said suites. Simple matter with the Container aware command.
But here comes the glitch. When I try to call a service that uses Symfony's security.authorization_checker service, the cli returns this error:
PHP Parse error: syntax error, unexpected ',' in /tmp/kahlan/data/www/project/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authorization/ExpressionLanguageProvider.php on line 55
The code of said file:
[...]
public function getFunctions()
{
return array(
new ExpressionFunction('is_anonymous', function () {
return '$trust_resolver->isAnonymous($token)';
}, function (array $variables) {
return $variables['trust_resolver']->isAnonymous($variables['token']);
}),
new ExpressionFunction('is_authenticated', function () {
return '$token && !$trust_resolver->isAnonymous($token)';
}, function (array $variables) {
return $variables['token'] && !$variables['trust_resolver']->isAnonymous($variables['token']);
}),
new ExpressionFunction('is_fully_authenticated', function () {
return '$trust_resolver->isFullFledged($token)';
}, function (array $variables) {
return $variables['trust_resolver']->isFullFledged($variables['token']);
}),
new ExpressionFunction('is_remember_me', function () {
return '$trust_resolver->isRememberMe($token)';
}, function (array $variables) {
return $variables['trust_resolver']->isRememberMe($variables['token']);
}),
new ExpressionFunction('has_role', function ($role) {
return sprintf('in_array(%s, $roles)', $role);
}, function (array $variables, $role) {
return in_array($role, $variables['roles']);
}),
);
}
[...]
Line 55 is the line of the last array element, thus said comma is the trailing comma.
The error is thrown only in cli.
An of course, I have tried removing the comma, everything works then perfectly. But obviously, I can't change Symfony's built-in classes.
So, How come PHP throws Parse Errors for a trailing comma in an array only in cli mode, and do you guys have any idea on how to fix this?
Thanks.
As seen in the kahlan-bundle repo, The problem was not in my code but seemed to be with kahlan.
Issue answered by Kahlan dev here.
Upgrading to the new kahlan version simply resolved the problem.
I have two routes /alpha and /beta configured in yml. In alphaAction a notice is placed in the flashbag and a redirecttoroute occurs. In betaAction the notice in the flashbag is read.
Sometimes I get 2 notices when I try /alpha in the browser and sometimes I get one notice.
Can someone explain what is happening, what I'm doing wrong.
public function alphaAction()
{
$this->get('session')->getFlashBag()->add("notice",mt_rand());
return $this->redirectToRoute("beta");
}
public function betaAction()
{
$notices= $this->get('session')->getFlashBag()->get('notice');
return new Response(implode($notices,", "));
}
Using the add method I could reproduce the issues you described. This can be fixed by using the set method and not the add (or setFlash) method.
public function alphaAction()
{
$this->get('session')->getFlashBag()->set("notice",mt_rand());
return $this->redirectToRoute("beta");
}
public function betaAction()
{
$notices= $this->get('session')->getFlashBag()->get('notice');
return new Response(implode($notices,", "));
}
I'm getting the following error in magento administration
Fatal error: Class 'Zend_Log' not found in /home/website/public_html/app/code/community/Uni/Fileuploader/Block/Adminhtml/Fileuploader/Edit/Tab/Products.php on line 241
This is a community extension, which has been working fine on my website. The error makes no sense to me, because the line 241 contains just a closing "}" character.
class Uni_Fileuploader_Block_Adminhtml_Fileuploader_Edit_Tab_Products extends Mage_Adminhtml_Block_Widget_Grid {
...
...
...
public function getRowUrl() {
return '#';
}
public function getGridUrl() {
return $this->getUrl('*/*/productgrid', array('_current' => true));
}
protected function getFileuploaderData() {
return Mage::registry('fileuploader_data');
}
protected function _getSelectedProducts() {
$products = $this->getRequest()->getPost('selected_products');
if (is_null($products)) {
$products = explode(',', $this->getFileuploaderData()->getProductIds());
return (sizeof($products) > 0 ? $products : 0);
}
return $products;
}
} // line 241, where error occurs
I can post the rest of the code, if you need it.
I noticed that if I upgrade to PHP 5.4 version the error disappears, but since 5.4 version causes other errors on my website, I have to continue using 5.3.
Any ideas on how to solve this?
The problem could be the name of one of the methods in your custom class.
Take for example the method name is getData() ,
Try searching for generic method names in your script, such as getData, which might be reserved by some of Magento’s core classes. I figure that these methods have predefined functionality, which your module is missing support for, and Zend then tries to write an exception to Zend log.
Reference link: netismine
I got the same error when rewriting a payment method.
public function authorize($payment, $amount)
Solved rewriting exactly the same main method:
public function authorize(Varien_Object $payment, $amount)
Magento 1.9.1.0/PHP 5.5
This is my URL:
http://serverHost:port/projectName/public/restaurants/create
This is the error message:
Open: UrlToProject\bootstrap\compiled.php
if (!is_null($route)) {
return $route->bind($request);
}
$others = $this->checkForAlternateVerbs($request);
if (count($others) > 0) {
return $this->getOtherMethodsRoute($request, $others);
}
throw new NotFoundHttpException();
}
protected function checkForAlternateVerbs($request)
Though the route does exist like this:
Route::resource('restaurants', 'RestaurantsController');
and the controller RestaurantsController has this method:
public function create()
{
return View::make('restaurants.create');
}
and the view absolutely exists. What am I doing wrong please?
I am working on Laravel 4.2.3 on Windows 7.
Also, I noticed these lock signs. is this wrong?
I found the problem myself
The project name has a capital letter case and I was calling it small letter :)