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

ask function: Call to a member function getOutput() #371

Closed
puxiaokang opened this issue Jun 19, 2015 · 5 comments
Closed

ask function: Call to a member function getOutput() #371

puxiaokang opened this issue Jun 19, 2015 · 5 comments

Comments

@puxiaokang
Copy link

Just for secure, I can't write host password in code. So I try ask function.

when I call ask or askHiddenResponse for ask password, the function throw this error:

Fatal error: Call to a member function getOutput() on a non-object in vendor/deployer/deployer/src/functions.php on line 511

example:

<?php
require 'recipe/symfony.php';
$password = askHiddenResponse("Host password: ");

server('prod', 'HOST', 22)
     ->user('USER')
     ->password($password);

If ask in task callback, It's success. but I can set server.password:

task('auth', function(){
    $password = askHiddenResponse("Host password: ");
    env('server.password', $password);
});
before('deploy', 'auth');

-- throw exception
The parameter `server.password` cannot be set, because `server` is protected.
@antonmedv
Copy link
Member

You can specify password to null:

server('prod', 'HOST', 22)
     ->user('USER')
     ->password(null);

And you will be asked for password.

@ZhukV can you add docs about this functionality?

@puxiaokang
Copy link
Author

Thanks

@staabm
Copy link
Contributor

staabm commented Mar 9, 2017

is ask and friends not supposed to be run at the top level?
(as I ran into the same error as I dont invoke it within a task it seems).

if this is the case it would be great to throw a proper exception which tells the dev that the function/method he is trying to use requires a Context (which means needs to be called within a task())

@antonmedv
Copy link
Member

if this is the case it would be great to throw a proper exception which tells the dev that the function/method he is trying to use requires a Context (which means needs to be called within a task())

@staabm this will be cool. Can you create PR with this?

@staabm
Copy link
Contributor

staabm commented Mar 10, 2017

Will do

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

3 participants