NotFoundHttpException in RouteCollection.php line 161 resource controller - laravel-5.3

I am using following code in routes/web.php
Route::resource('affiliate/account', 'Affiliate\AccountController',
[
'pSignup' => 'affiliate.signup',
'gSettings' => 'affiliate.settings'
]
);
Controller is in app/Http/Controllers/Affiliate/AccountController.php
I am getting following error.
NotFoundHttpException in RouteCollection.php line 161
Any suggestions, what is causing this error?

Related

How to solve Twig_Error_Runtime in Symfony 3

I have inherited a rather complicated Symfony 3 project (I'm using Laravel mostly nowadays - it's been years since I used Symfony) so this is a bit out of my wheelhouse.
I did a composer update and it built ok.
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating twig/twig 1.x-dev (e8555dc => 1445246): Checking out 1445246d8e
Writing lock file
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
// Clearing the cache for the dev environment with debug
// true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
Trying to install assets as relative symbolic links.
-- -------- ----------------
Bundle Method / Error
-- -------- ----------------
[OK] All assets were successfully installed.
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget
I cleared the cache
php bin/console cache:clear --no-warmup --env local
When I browse to my local development URL, I get:
Whoops, looks like something went wrong.
(4/4) Twig_Error_Runtime
An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0").
in exception_full.html.twig (line 1)
at Twig_Template->displayWithErrorHandling(array('status_code' => 500, 'status_text' => 'Internal Server Error', 'exception' => object(FlattenException), 'logger' => object(Logger), 'currentContent' => '', 'app' => object(AppVariable)), array('head' => array(object(__TwigTemplate_ed2c7b0206a4a8ba0c01ceb7e7a7f0ba342d3cbf55c912fe1f34e6abd35411c0), 'block_head'), 'title' => array(object(__TwigTemplate_ed2c7b0206a4a8ba0c01ceb7e7a7f0ba342d3cbf55c912fe1f34e6abd35411c0), 'block_title'), 'body' => array(object(__TwigTemplate_ed2c7b0206a4a8ba0c01ceb7e7a7f0ba342d3cbf55c912fe1f34e6abd35411c0), 'block_body')))
in Template.php (line 403)
<snip/>
(3/4) ContextErrorException
Notice: Undefined offset: 0
in Profiler.php (line 23)
at Twig_Extension_Profiler->enter(object(Twig_Profiler_Profile))
in ProfilerExtension.php (line 40)
<snip/>
(2/4) Twig_Error_Runtime
An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0").
in base.html.twig (line 11)
at Twig_Template->displayBlock('javascripts', array('env' => 'local', 'app' => object(AppVariable)), array('title' => array(object(__TwigTemplate_e199b3b21ccad34239564ea288dce2bfa2f11212622c2c75863848c603e82b70), 'block_title'), 'stylesheets' => array(object(__TwigTemplate_e199b3b21ccad34239564ea288dce2bfa2f11212622c2c75863848c603e82b70), 'block_stylesheets'), 'body' => array(object(__TwigTemplate_888836406c51f4232014f646f747310c541800b61ef418c11fbfcee42a1afe9b), 'block_body'), 'javascripts' => array(object(__TwigTemplate_e199b3b21ccad34239564ea288dce2bfa2f11212622c2c75863848c603e82b70), 'block_javascripts')))
in Environment.php(467) : eval()'d code (line 51)
<snip/>
(1/4) ContextErrorException
Notice: Undefined offset: 0
in Profiler.php (line 23)
at Twig_Extension_Profiler->enter(object(Twig_Profiler_Profile))
in ProfilerExtension.php (line 40)
Since this appears to be an issue with vendor files, I'm not sure where to go from here.
The last error in the logs is
[2018-03-02 15:56:53] request.CRITICAL: Exception thrown when handling an exception (Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Notice: Undefined offset: 0"). at /Projects/myproject/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig line 1) {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"Notice: Undefined offset: 0\"). at /Projects/myproject/vendor/symfony/symfony/src/Symfony/Bundle/TwigBundle/Resources/views/Exception/exception_full.html.twig:1, Symfony\\Component\\Debug\\Exception\\ContextErrorException(code: 0): Notice: Undefined offset: 0 at /Projects/myproject/vendor/twig/twig/lib/Twig/Extension/Profiler.php:23)"} []
Try to add this line in composer.json
"twig/twig": "2.4.4"
For me worked.
It seems the last updates for twig 2.4.5 had this problem.
I found the answer here:
https://github.com/twigphp/Twig/issues/2627

Drupal 7 - Add node edit form into a 'Simple page'

I'm trying to add the edit form of an existing node to a Basic page. Based on a given nid.
This problem seemed simple, however my attempt resulted in the following error report:
$node = node_load(array('nid' => 83));
$output = drupal_get_form($node->type .'_node_form', $node);
echo $output;
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /home/PAE/www/paemanu/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /home/PAE/www/paemanu/includes/entity.inc).
Notice: Trying to get property of non-object in eval() (line 3 of /home/PAE/www/paemanu/modules/php/php.module(80) : eval()'d code).
Notice: Undefined index: _node_form in drupal_retrieve_form() (line 806 of /home/PAE/www/paemanu/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_node_form' not found or invalid function name in drupal_retrieve_form() (line 841 of /home/PAE/www/paemanu/includes/form.inc).
Notice: Undefined variable: output in eval() (line 3 of /home/PAE/www/paemanu/modules/php/php.module(80) : eval()'d code).
Notice: Undefined index: user-project in drupal_retrieve_form() (line 806 of /home/PAE/www/paemanu/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user-project' not found or invalid function name in drupal_retrieve_form() (line 841 of /home/PAE/www/paemanu/includes/form.inc).
I've been on this issue for many hours, any help is greatly appreciated.
Try this code:
$nid = 83;
$node = node_load($nid);
$type = $node->type;
module_load_include('inc', 'node', 'node.pages');
$form = drupal_get_form('node_edit_'.$type, $node);
render($form);

MissingOptionsException: The required option "class" is missing

I am getting the above error when trying to use a entity field type in a form.
I am using Symfony 2.6.0.
My class has a category field defined as:
/**
* #ORM\ManyToOne(targetEntity="Category", inversedBy="parent")
* #ORM\JoinColumn(name="category_id", referencedColumnName="id")
*/
protected $category;
The category class is defined as:
/**
* #ORM\OneToMany(targetEntity="Parent", mappedBy="category")
*/
protected $parents;
My form type has definition for the category as:
->add('category', 'entity', array(
'class' => 'AppBundle:Category',
'property' => 'name'
In my controller I am calling it with:
->add('category', 'entity')
The stack trace is below:
Symfony\Component\OptionsResolver\Exception\MissingOptionsException: The required option "class" is missing.
at n/a
in \project\vendor\symfony\symfony\src\Symfony\Component\OptionsResolver\OptionsResolver.php line 757
at Symfony\Component\OptionsResolver\OptionsResolver->resolve(array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\ResolvedFormType.php line 109
at Symfony\Component\Form\ResolvedFormType->createBuilder(object(FormFactory), 'category', array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy.php line 82
at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->createBuilder(object(FormFactory), 'category', array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormFactory.php line 87
at Symfony\Component\Form\FormFactory->createNamedBuilder('category', 'entity', null, array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php line 106
at Symfony\Component\Form\FormBuilder->create('category', 'entity', array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php line 268
at Symfony\Component\Form\FormBuilder->resolveChildren()
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php line 216
at Symfony\Component\Form\FormBuilder->getForm()
in \project\src\AppBundle\Controller\TheController.php line 78
at AppBundle\Controller\TheController->editAction('30', object(Request))
in line
at call_user_func_array(array(object(TheController), 'editAction'), array('30', object(Request)))
in \project\app\bootstrap.php.cache line 3008
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in \project\app\bootstrap.php.cache line 2970
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in \project\app\bootstrap.php.cache line 3119
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in \project\app\bootstrap.php.cache line 2364
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in \project\web\app_dev.php line 28
Any help would be very much appreciated.
Jay
It looks like you have created a form class, but are recreating the form in the controller rather than using the form class.
In my controller I am calling it with:
->add('category', 'entity')
You should either use the same class and property options as you did in the form class, or better, use the form class in the controller instead of recreating the form.
$this->createForm(new ParentType(), $parent);

Symfony2 Shell.php error on production server

I get the following error in app_dev.php on my production server:
ErrorException: Notice: Undefined variable: output in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php line 59
in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php
line 59
at ErrorHandler->handle('8', 'Undefined variable: output', '/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php',
'59', array('command' => 'find')) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php
line 59
at Shell->testCommand('find') in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php
line 123
at AbstractFindAdapter->isSupported() in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php
line 30
at GnuFindAdapter->isSupported() in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php
line 700
at Finder->searchInDirectory('/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Validator/Resources/translations')
in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php
line 628
at Finder->getIterator() in /www/acme/www/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
line 555
at FrameworkExtension->registerTranslatorConfiguration(array('fallback'
=> 'pl', 'enabled' => true), object(ContainerBuilder)) in /www/acme/www/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
line 106
at FrameworkExtension->load(array(array('translator' => array('fallback' => 'pl'), 'secret' =>
'eea6ad638afadb62cd7bc360e98f7d3b', 'router' => array('resource' =>
'/www/acme/www/app/config/routing.yml', 'strict_requirements' =>
true), 'form' => true, 'csrf_protection' => true, 'validation' =>
array('enable_annotations' => true), 'templating' => array('engines'
=> array('twig')), 'trust_proxy_headers' => false, 'default_locale' => 'pl', 'session' => null), array('router' => array('resource' =>
'/www/acme/www/app/config/routing_dev.yml'), 'profiler' =>
array('only_exceptions' => false))), object(ContainerBuilder)) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php
line 42
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php
line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
line 119
at Compiler->compile(object(ContainerBuilder)) in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
line 494
at ContainerBuilder->compile() in /www/acme/www/app/bootstrap.php.cache line 950
at Kernel->buildContainer() in /www/acme/www/app/bootstrap.php.cache line 859
at Kernel->initializeContainer() in /www/acme/www/app/bootstrap.php.cache line 571
at Kernel->boot() in /www/acme/www/app/bootstrap.php.cache line 614
at Kernel->handle(object(Request)) in /www/acme/www/web/app_dev.php line 29
Everything works fine on my localhost so it can be something wrong with the server configuration.
Hosting provider has turned PHP exec function off because of the security reasons.
That's why above error occurred.
Does anyone know if its possible to bypass exec function in Symfony2 - I mean if it's possible to run symfony2 on the server with exec function turned off?
I've got the same problem with my hosting, with php safe_mode off. Actually there is a todo, but I dont know when they will fix it.
// todo: find a better way (command could not be available)
exec('command -v '.$command, $output, $code);
as seen in Symfony\Component\Finder\Shell\Shell;

Wordpress Theme development: Getting Undefined index error

hello I am a wordpress theme developer. i created a theme which works fine in WP_DEBUG=False but gets undefined index error when I set WP_DEBUG=True
My theme has an options page, whenever i click on save i get these errors:
Notice: Undefined index: ang_temp in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_breadcrumbs in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_social in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_tw in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_fb in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_ms in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Notice: Undefined index: ang_hide_rss in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 147
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php:147) in C:\xampp\htdocs\wordpress\wp-content\themes\Angelia\functions.php on line 156
Here is my themes functions.php
I don't know what I am doing wrong. I have very very little knowledge about php. Hope guys with php knowledge or wordpress theme development knowledge can help.
146. foreach ($options as $value) {
147. update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
The bit of code which is producing this error (above) is not checking whether $_REQUEST[ $value['id'] ] exists. The errors you are getting suggest that it doesn't (you will only get this notice with full error checking enabled). Other parts of your code are checking the existence of this variable before using it (so they are OK) and would suggest you should be doing the same here.
You say your theme works OK when debug is off, so this would suggest that you only need to check the existence of this variable before using it. Something like (replacing the 2 lines above):
foreach ($options as $value) {
if (isset($_REQUEST[ $value['id'] ])) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] );
}
}
However, although this should prevent your 'errors' (they are only notices really), I'm unfamiliar with wordpress themes so can't say for sure whether this is expected behaviour or whether there is something underlying which is at fault.

Resources