Laravel Key Generate Not Working
I have a table in my database called keys
that has this structure:
This post is exactly about what the title said: deploying a Laravel application to Heroku with GitLab CI/CD. As I needed to do it I unfortunately didn’t manage to find any tutorial or post about. In fact, almost everything is configured for you out of the box. The authentication configuration file is located at config/auth.php, which contains several well documented options for tweaking the behavior of the authentication services. At its core, Laravel's authentication facilities are made up of 'guards' and 'providers'.
- Mar 31, 2018 In this video we will see How to get YouTube API key. So follow the steps: 1. Search for Google Developers Console and visit https://console.cloud.google.com.
- So i have check that directory.env file is not there but.env.example file only there so i created that file and update database name, database username, database password after that 'php artisan key:generate' command is worked that key was generated above 32 characters and its get base64:somethingsstrings with above 32 characters i think.
Every time a user logs into my site, I need to generate a new token_id
and token_key
set for that user. How can I generate a random token for both the token_id
and the token_key
while keeping the two values unique?
For example, if:
token_id
isdfbs98641aretwsg
,token_key
issdf389dxbf1sdz51fga65dfg74asdf
Meaning:
There can be no other row in the table with that combination of tokens. How can I do this?
I’d avoid including an extra package for a case like this one. Something like:
…should do. Replace model name with yours, if different from ‘User’, and use your or suggested functions for creating random strings.
In terms of generating the tokens, you could use one of Laravel’s Helper Functions; str_random()
.
This will generate a random string of a specified length, e.g str_random(16)
will generate a random string of 16 characters (upper case, lower case, and numbers).
Depending on how you are using the tokens, do they really need to be completely unique? Given that they will match to a user, or I assume you may be using the token_id
and then verifying this against the token_key
does it really matter if there is a double up of one of them? – although the chances of this are extremely small!
However, if you do need them to be truly unique you can always use a validator with the unique
constraint. Using this package you could also test that the two of them are unique too with unique_with
. And then if the validator fails then it generates a new token as needed.
Based off your examples, you would be using str_random(16)
for token_id
and str_random(30)
for the token_key
.
Tags: dom, laravel, random
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Key figures of the beat generation.
Sign upHave 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.
Php Artisan Key Generate Not Working
Already on GitHub? Sign in to your account
Comments
commented Oct 26, 2017
Description:I'm using the GIT version control for my Laravel project. The problem is when I clone the repository, run the composer install, create the .env and run php artisan key: generate the following error is displayed: [RuntimeException] Steps To Reproduce:
Now simulating another programmer on my team, he would do the clone and execute the commands:
|
commented Oct 26, 2017
It has a detail, if I put any other key manually in the .env (such as base64: JYY8rk4 + k1tXELhyZ68BfpuVfoBhrHdXf5vPxyS7zAM =) and run php artisan key: generate, it works. If it does not work, it will not work. |
commented Oct 27, 2017
I found someone with the same problem as mine (Link). In my case I am encrypting the session. I did the test by setting it to false, the command did not work. I did the test by commenting on my Macros code, it worked perfectly. |
commented Oct 27, 2017
I was able to solve the problem. There should be some BUG when using Form::macro() in a Middleware. I did some more research and discovered that there is also the Html::macro(). By swapping these tags in the macros I created, the problem in generating the key is gone. So I conclude then that my problem is solved and open to you who may be going through it. Windows ten download for mac. |