Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not recognize honeypot method #2

Open
enchance opened this issue Apr 8, 2014 · 36 comments
Open

Does not recognize honeypot method #2

enchance opened this issue Apr 8, 2014 · 36 comments

Comments

@enchance
Copy link

enchance commented Apr 8, 2014

Might just be me but I'm getting: An exception has been thrown during the rendering of a template ("Method honeypot does not exist.") in my view. I'm using Twig and access your method as such, form_honeypot('hname', 'htime').

I also have my own custom macros which I'm able to access as form_mymacroname('xxx') so I don't think it's the macro but I might be wrong on this.

msurguy pushed a commit that referenced this issue Apr 18, 2014
Make truly PHP 5.3 compatible.
@lud
Copy link

lud commented Apr 29, 2014

Hi,

Does Laravel find the service provider as expected ? Can you call its methods ?

@enchance
Copy link
Author

It's really not working. I tried using <?php echo Form::honeypot('h', 't'); ?> on a non-twig view and I still got Method honeypot does not exist.. Everything is installed exactly as instructed.

@msurguy
Copy link
Owner

msurguy commented Apr 30, 2014

Are you sure you have the service provider added in the app.php? 'Msurguy\Honeypot\HoneypotServiceProvider',

@enchance
Copy link
Author

Yes. Btw, I'm using L4.1. Perhaps this version is affecting your package?

@lud
Copy link

lud commented May 1, 2014

I'm using L4.1 and it's ok.

I believe you must add the service provider at the end of the providers array, not at the top. It that all right ?

@enchance
Copy link
Author

enchance commented May 4, 2014

No, it didn't. Let me check this might be an isolated incident having to do with some of the core classes I've extended.

@garygreen
Copy link
Contributor

Does my recent changes to the service provider fix this issue?

@rombat
Copy link

rombat commented Mar 20, 2015

I have the exact same problem. I'm using Laravel 4.2 and I've added 'Msurguy\Honeypot\HoneypotServiceProvider' to app.php

@garygreen
Copy link
Contributor

@rombat are you using twig too? Do you use twigbridge or anything like that?

@rombat
Copy link

rombat commented Mar 20, 2015

Nope I'm using Blade.
I've just added {{ Form::honeypot('my_name', 'my_time') }} in a form to test Honeypot.

@rombat
Copy link

rombat commented Mar 20, 2015

Here's the Exception:


Open: /home/vagrant/Code/laravel/vendor/laravel/framework/src/Illuminate/Support/Traits/MacroableTrait.php

        public static function __callStatic($method, $parameters)
        {
            if (static::hasMacro($method))
            {
                return call_user_func_array(static::$macros[$method], $parameters);
            }

            throw new \BadMethodCallException("Method {$method} does not exist.");
        }


Exception message: Method honeypot does not exist.

@garygreen
Copy link
Contributor

Can you paste your app.php providers array too please.

@rombat
Copy link

rombat commented Mar 20, 2015

    'providers' => array(

        'Illuminate\Foundation\Providers\ArtisanServiceProvider',
        'Illuminate\Auth\AuthServiceProvider',
        'Illuminate\Cache\CacheServiceProvider',
        'Illuminate\Session\CommandsServiceProvider',
        'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
        'Illuminate\Routing\ControllerServiceProvider',
        'Illuminate\Cookie\CookieServiceProvider',
        'Illuminate\Database\DatabaseServiceProvider',
        'Illuminate\Encryption\EncryptionServiceProvider',
        'Illuminate\Filesystem\FilesystemServiceProvider',
        'Illuminate\Hashing\HashServiceProvider',
        'Illuminate\Html\HtmlServiceProvider',
        'Illuminate\Log\LogServiceProvider',
        'Illuminate\Mail\MailServiceProvider',
        'Illuminate\Database\MigrationServiceProvider',
        'Illuminate\Pagination\PaginationServiceProvider',
        'Illuminate\Queue\QueueServiceProvider',
        'Illuminate\Redis\RedisServiceProvider',
        'Illuminate\Remote\RemoteServiceProvider',
        'Illuminate\Auth\Reminders\ReminderServiceProvider',
        'Illuminate\Database\SeedServiceProvider',
        'Illuminate\Session\SessionServiceProvider',
        'Illuminate\Translation\TranslationServiceProvider',
        'Illuminate\Validation\ValidationServiceProvider',
        'Illuminate\View\ViewServiceProvider',
        'Illuminate\Workbench\WorkbenchServiceProvider',
        'Barryvdh\Debugbar\ServiceProvider',
        'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
        'Roumen\Asset\AssetServiceProvider',
        'Way\Generators\GeneratorsServiceProvider',
        'DaveJamesMiller\Breadcrumbs\ServiceProvider',
        'Jenssegers\Agent\AgentServiceProvider',
        'Arg\Tagcloud\TagcloudServiceProvider',
        'Former\FormerServiceProvider',
        'Bootstrapper\BootstrapperServiceProvider',
        'Lib\Search\SearchServiceProvider',
        'Lib\Validation\ValidationExtensionServiceProvider',
        'Kmd\Logviewer\LogviewerServiceProvider',
        'Indatus\Dispatcher\ServiceProvider',
        'BigName\BackupManager\Integrations\Laravel\BackupManagerServiceProvider',
        'Spatie\Glide\GlideServiceProvider',
        'Msurguy\Honeypot\HoneypotServiceProvider',
    ),

@garygreen
Copy link
Contributor

if possible, can you comment out/remove these providers and see if it honeypot works?

    'Former\FormerServiceProvider',
    'Bootstrapper\BootstrapperServiceProvider',

@garygreen
Copy link
Contributor

Also are you using the latest dev-master of honeypot? Latest tagged version of honeypot is quite old

@rombat
Copy link

rombat commented Mar 20, 2015

Yep, I have "vinicius73/seotools": "dev-master".
It was due to Former actually. My form was opened/closed with Former.
I tried {{ Former::honeypot('my_name', 'my_time') }} and it works. Well, actually, sort of: only the 'my name' field is added, 'my time' is not.

Is there a way to make it work? I'm using Former and Bootstrapper\Form in almost all my forms.

@garygreen
Copy link
Contributor

Weird how the my time field is not added, what's the actual raw HTML output for the honeypot section? You got quite a lot of dependencies to be honest, could be anything.

I did take a look at former and bootstrapper service provider on github as I originally suspected it was replacing Laravel's built in form and therefore overriding the macros, but that doesn't seem like the case. Can you setup a real bare repository on github that replicates the issue in the min number of steps I can take a look.

@iBotPeaches
Copy link

Ever since this commit: f18c81f

My regular 4.2 application fails with honeypot method does not exist. I reverted back to the commit prior to that one and everything worked.

@garygreen
Copy link
Contributor

@iBotPeaches what's in your app.providers array?

@iBotPeaches
Copy link

    'providers' => array(
        'Illuminate\Foundation\Providers\ArtisanServiceProvider',
        'Illuminate\Auth\AuthServiceProvider',
        'Illuminate\Cache\CacheServiceProvider',
        'Illuminate\Session\CommandsServiceProvider',
        'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
        'Illuminate\Routing\ControllerServiceProvider',
        'Illuminate\Cookie\CookieServiceProvider',
        'Illuminate\Database\DatabaseServiceProvider',
        'Illuminate\Encryption\EncryptionServiceProvider',
        'Illuminate\Filesystem\FilesystemServiceProvider',
        'Illuminate\Hashing\HashServiceProvider',
        'Illuminate\Html\HtmlServiceProvider',
        'Illuminate\Log\LogServiceProvider',
        'Illuminate\Database\MigrationServiceProvider',
        'Illuminate\Pagination\PaginationServiceProvider',
        'Illuminate\Queue\QueueServiceProvider',
        'Illuminate\Redis\RedisServiceProvider',
        'Illuminate\Remote\RemoteServiceProvider',
        'Illuminate\Database\SeedServiceProvider',
        'Illuminate\Session\SessionServiceProvider',
        'Illuminate\Translation\TranslationServiceProvider',
        'Illuminate\Validation\ValidationServiceProvider',
        'Illuminate\View\ViewServiceProvider',
        'Illuminate\Workbench\WorkbenchServiceProvider',
        'GrahamCampbell\Markdown\MarkdownServiceProvider',
        'App\Form\Providers\FormBuilderServiceProvider',
        'App\Auth\Providers\PasswordBrokerServiceProvider',
        'Intervention\Image\ImageServiceProvider',
        'Zizaco\Entrust\EntrustServiceProvider',
        'Msurguy\Honeypot\HoneypotServiceProvider',
        'Laravel\Cashier\CashierServiceProvider',
        'Appitventures\Phpgmaps\PhpgmapsServiceProvider',
        'Snowfire\Mail\MailServiceProvider',
        'Bugsnag\BugsnagLaravel\BugsnagLaravelServiceProvider',

@garygreen
Copy link
Contributor

Can you comment out App\Form\Providers\FormBuilderServiceProvider and try if honeypot works?

@iBotPeaches
Copy link

Yes that fixed it, but then removed all my custom Form functions that I had created, so can't really use that fix.

@garygreen
Copy link
Contributor

Of course not, just trying to find the cause. Can you post your FormBuilderServiceProvider?

@iBotPeaches
Copy link

FormBuilderServiceProvider.php

<?php namespace App\Form\Providers;

use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
use App\Form\FormBuilder as FormBuilder;

class FormBuilderServiceProvider extends IlluminateServiceProvider {

    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = true;

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bindShared('formbuilder', function($app)
        {
            $form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());

            return $form->setSessionStore($app['session.store']);
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return array('formbuilder');
    }
}

@garygreen
Copy link
Contributor

Does your FormBuilder extends Laravels one? How are you using your custom form builder, do you have a facade?

@iBotPeaches
Copy link

Yep my custom FormBuilder extends laravel.

use \Illuminate\Html\FormBuilder as IlluminateFormBuilder;

class FormBuilder extends IlluminateFormBuilder {

Which then changes the Facade in app/config to point to my custom one, allowing me to use my custom functions in addition to the laravel ones.

        'Form'            => 'App\Form\FormBuilderFacade',

@garygreen
Copy link
Contributor

The new service provider in honeypot will listen for when the form alias get's resolved from the container, then register all the macros. The default alias in Laravel is form but I notice you've changed it to formbuilder in your provider. Can you try changing it to just form which will override Laravel's built in one.

@iBotPeaches
Copy link

That worked. Thank you!

No idea why I used formbuilder vs form.

@rombat
Copy link

rombat commented Mar 23, 2015

@garygreen : here's a test repository with the error: https://github.com/rombat/test-laravel-honeypot
It's just a fresh install of Laravel 4.2 with the packages I use on my project, and the default "hello" view edited with honeypot method.

@garygreen
Copy link
Contributor

I've created a PR which will help resolve #25

@rombat
Copy link

rombat commented Mar 23, 2015

Thanks!

@purplegriffon
Copy link

Getting this too using with L5. Both providers and aliases arrays are setup correctly.

@garygreen
Copy link
Contributor

@purplegriffon are you using the Honeypot facade?

@purplegriffon
Copy link

@garygreen I have it listed in the aliases array and in my views I'm using {{ Form::honeypot('pot', 'pot_time') }}, that's what's breaking.

@purplegriffon
Copy link

Ah, ignore me. I see the usage has changed. Apologies.

@garygreen
Copy link
Contributor

Yup, we got rid of the form macro as it was a bit of a headache to maintain especially as the form builder is deprecated/no longer maintained, and it's usage didn't really add much value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants