Talking about frameworks may be the first question in the head is
"How can I create Authentications?".
We will give you an explanation easily and everything is ready in one command!
By using Artisan Command you can easily create authentication and maybe you need multiple auth? we will explain it in detail to you for free! Yaayy! nice!
Hamorny Framework will make you very easy to do the job and give you how beautiful the universe with its rhythm.
Let's talk about authentication. In a website application of course you want to create a control room with a key that may be just you I have it like Website Blog or you want to give keys to certain spaces to your website users like social media, etc.
Check if you already have the latest version of Harmony Framework, if you are in doubt or do not want to be hard. Simply create a project with the latest Harmony Installer. Make sure you have updated Harmony Installer composer global update.
Then open your terminal or commad prompt, go to the framework harmony directory project. When the command to create authentication as follows:
Before you make your directory authentication look like this:
# Controllers Folder
app/Controllers/
└── Controller.php
# Migrations Folder
app/Database/
└── migrations
# Resources Views Folder
resources/views/
├── error
│ └── 404.twig
└── welcome.twig
Now type and hit enter!
> php artisan make:auth-full # enter
Create Full Auth Scaffolding Successfully!
After created, now check the Controllers, Migrations, and Resources directory:
# Controllers Folder
app/Controllers/
├── Auth
│ ├── AuthController.php
│ └── PasswordController.php
└── Controller.php
# Migrations Folder
app/Database/
└── migrations
└── 20180125142442_Users.php
# Models now available for you
app/Models/
└── Users.php
# Resources Views Folder
resources/views/
├── auth
│ ├── forgot-password.twig
│ ├── home.twig
│ ├── password
│ │ ├── change.twig
│ │ ├── forgot-password.twig
│ │ └── reset-password.twig
│ ├── signin.twig
│ └── signup.twig
├── email
│ └── forgot-password-email.twig
├── error
│ └── 404.twig
├── partials
│ └── flash.twig
└── welcome.twig
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'harmony.users' doesn't exist (SQL: select * from `users` where `users`.`id` is null limit 1)
If you have not created a database, then create a database with the name according to your needs. replace the database settings in the ".env" file include the database username and password. Then create a Users table in your database.
We recommend it with Migrations files already in the folder "migrations" to create users table.
Copy and paste the following script into your migration file.
Check the status of the database whether the table still has a down status which means you have not migrated to the database server. To create a user table up to the database server you need to type the following command:
then you can use flag -t to up your specific migrations.
Now you can refresh your page in browser and Viola !! now you already have authentication on your website. But you do not have a user yet. to make your user click "register" or you can use Harmony Tinker to create your user data.
now you do not have users, let's make it with tinker!
Now check your Users Models in the Models folder to make sure your table's fillable columns.
delete the comment on Class Users and replace with the script as follows:
In the next step you can use those models on the Controller you created.