軽くて使いやすいPHPフレームワーク。
DejFrameworkは、簡潔さ、シンプルさ、理解可能性に焦点を当てたシンプルで最小限のPHP MVCフレームワークです。構文は主にLaravelからインスピレーションを受けています。 DejFrameworkは、Ata Marzbanによって学士号の最終プロジェクトのために開発されました。
#installation
composer installを実行します。フレームワークがリクエストが来たときに何をすべきかを知るために、アプリケーションのルートを/app/routes.phpに設定する必要があります。簡単に行われます。
ルートは、指定されたURLに指定されたメソッドを使用して要求が行われた場合に実行するHTTPメソッド、URL、および宛先で構成されます。ルートを設定せずに実行されるものはありません。目的地として閉鎖を渡すことができます:
[/app/routes.php]
Route:: set ( " GET " , " / " , function (){
return " Hello World! " ;
});このコードは、yoursite.comでサイトにアクセスすると「Hello World」を出力します。
[/app/routes.php]
Route:: set ( " GET " , " /some/url " , function (){
return " This is some url! " ;
});このコードは「これはいくつかのURLです!」あなたがあなたのサイトにyoursite.com/some/urlにアクセスした場合。
[/app/routes.php]
Route:: set ( " POST " , " /do/something " , function (){
return " Here you should write your own code to do the things you want. " ;
});このコードは、postメソッドを使用してyoursite.com/do/somethingにアクセスすると実行されます。 (フォームまたはAPI呼び出しから)
閉鎖またはコントローラーに文字列、オブジェクト、配列、またはビュー(後述)を返すことができます。文字列は直接出力されますが、オブジェクトまたはビューはJSONおよび出力に自動的に変換され、ビューは出力にレンダリングされます。
次の部分では、閉鎖ではなくコントローラーにルートを向ける方法を学びます。
MVCパターンでは、アプリケーションロジックをコントローラーに配置する必要があることは、ベストプラクティスと考えられています。
[/app/controllers/YourController.php]
<?php
namespace app controllers;
class YourController extends dej mvc Controller
{
public static function yourAction ()
{
return " This is the right way to do it! " ;
}
}重要:上記の例でわかるように、PSR-0オートローダーが正しく機能するには、アプリケーションにクラスを追加するときは次の規則に従う必要があります。
それでは、コントローラーを機能させる方法を学び続けましょう。
[/app/routes.php]
Route:: set ( " GET " , " / " , " YourController@YourAction " );指定されたコントローラーで指定されたアクションは、ルートがトリガーされるときに実行されます。
クラスを絶えずインスタンス化し、それらに依存を渡すことは、PHP開発の繰り返しのタスクになる可能性があります。 dej Appサービスプロバイダーは、このプロセスを可能な限り乾燥させることを目指しています。このサービスプロバイダーを使用すると、各ファイルに使用されたステートメントを追加して依存関係を渡す必要はありません。この例を取ります:
/**
* Without a Service Provider
* when you want to build a query
*/
use dej db Connection ;
$ connection = Connection:: getInstance ();
use dej db Query ;
$ query = new Query ( $ connection );
$ result = $ query -> select ()-> from ( ' someTable ' )-> getAll ();
return $ result ;そして、これはクエリビルダーを使用するたびに繰り返す必要があります。今、サービスプロバイダーを使用してください:
use dej App ;
return App:: Query ()-> select ()-> from ( ' some_table ' );それでおしまい! DEJ/app.phpを見て、それがどのように機能するかを確認してください。 「クエリ」という名前の静的メソッドがアプリクラスで呼び出されます。クエリクラスをインスタンス化し、コンストラクターパラメーターとして接続インスタンスを渡します。ケーキ!
#request dejhttpRequestクラスにリクエストとの対話が簡単になります。次の例を見てください。
//check if request is ajax or not
$ result = App:: Request ()-> isAjax ();
//returns $_GET['name'];
$ result = App:: Request ()-> get ( ' name ' );
//returns $_POST['name'];
$ result = App:: Request ()-> post ( ' name ' );
//returns $_REQUEST;
$ result = App:: Request ()-> all (); #Response dejhttpResponseクラスの応答パラメーターの設定を簡単にすると、HTTP応答コードまたはヘッダーを設定する場合は、コントローラーに応答を返す必要があります。次の例を見てみましょう。
class IndexController extends dej mvc Controller
{
public static function index ()
{
return App:: Response ()-> code ( 404 )-> header ( ' HTTP/1.1 404 Not Found ' );
}
}簡単にリダイレクトできます。
//in the controller
return App:: Response ()-> redirect ( ' /login ' );
//redirect with errors
App:: Response ()-> redirect ( ' / ' )-> withErrors ([ ' login ' => ' login unsuccessful! maybe password is wrong. ' ]);エラーでリダイレクトすると、セッションのエラーが点滅します(後で説明します)。
構成:最初に/config.jsonにデータベース構成を入力します。 DejFrameworkは、3層アーキテクチャでデータベースを扱います。
レイヤー1-データベース接続オブジェクト:これにより、Singleton Abstractクラスが拡張されます。つまり、初めて呼ばれるのは一度だけインスタンス化されるということです。 DejFrameworkに関する他のサービスもこのようなものです。クエリを実行するたびにDBに接続するオーバーヘッドを防ぐため。使用方法は次のとおりです。
//simple query
$ result = App:: Connection ()-> executeQuery ( " SELECT * FROM some_table " );
//NonQuery: a query that doesn't return rows, only the number of affected rows.
$ result = App:: Connection ()-> executeNonQuery ( " DELETE FROM some_table WHERE some_field = 'some_value' " );
//A Query using prepared statements, To protect against SQL Injection.
$ result = App:: Connection ()-> executeQuery ( " SELECT * FROM some_table WHERE some_field = ? " , [ " some_value " ]);
//A Query using prepared statements, To protect against SQL Injection. With Multiple Parameters.
$ result = App:: Connection ()-> executeQuery ( " SELECT * FROM some_table WHERE some_field = ? AND another_field = ? " , [ $ some_value , " another_value " ]);
//A Query using prepared statements, To protect against SQL Injection. With Named Parameters.
$ result = App:: Connection ()-> executeQuery ( " SELECT * FROM some_table WHERE some_field = :some_value_name
AND another_field = :another_value_name " ,
[ " :some_value_name " => $ some_value ,
" another_value_name " => " another_value " ]); use dejApp; 。
レイヤー2-クエリビルダー:このクラスはクエリを構築し、接続クラスを使用して安全な準備ステートメントを使用して実行します。新しいクエリごとにインスタンス化する必要があります。これは、Service Poviderセクションの例で見たように、 App::Query()を入力するたびに、 /dej /アプリによって自動的に行われます。メソッドチェーンを使用して、クエリを作成できます。以下の例をご覧ください。
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> getAll ();
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> getOne ();
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> getJson ();
$ query = App:: Query ()-> select ()-> from ( ' users ' )-> getQuery ();ご覧のとおり、DEJクエリビルダーを使用するのはシンプルです。コールアプリ:: query()を使用し、新しい、依存関係の照射クエリクラスを自動的に渡し、次にメソッドをチェーンして、select()、from getOne() )などの条件をgetAll()するためにメソッドをチェーンします。 getJson() )、または構築されたクエリ( getQuery() )。結果は、簡単に使用できるSTDCLASS形式でフェッチされています。クエリの最後にGETメソッドのいずれかを使用しないと、結果が取得されないことに注意する価値があります。また、たとえば、複数の行と複数のステップでメソッドを連鎖させることができます。
$ query = App:: Query ()-> select ();
if ( $ somecondition == true ) $ query -> from ( ' users ' );
else $ query -> from ( ' another_table ' );
$ result = $ query -> getAll ();次の例では、クエリビルダーで利用可能な他の方法を見てみましょう。
//All queries will be executed using prepared statements and parameters will be handled automatically.
//SELECT Queries:
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> where ( ' id ' , ' = ' , ' 22 ' )-> getAll ();
//you can omit the operator and it uses '=' by default
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> where ( ' id ' , ' 22 ' )-> getAll ();
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> where ( ' city ' , ' = ' , ' Berlin ' )
-> andWhere ( ' age ' , ' > ' , ' 20 ' )-> getAll ();
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> where ( ' city ' , ' = ' , ' Berlin ' )
-> orWhere ( ' city ' , ' = ' , ' Paris ' )-> getAll ();
$ result = App:: Query ()-> select ()-> from ( ' users ' )-> orderBy ( ' age ' , ' DESC ' )
-> limit ( 25 )
-> offset ( 50 )-> getAll ();
//INSERT Query:
$ affectedRows = App:: Query ()-> insertInto ( ' users ' )-> values ([ " username " => " jameshetfield " ,
" password " => " 19831983 " ,
" city " => " Downey " ])-> execute ();結果を返さないクエリは、 php execute()で実行する必要があり、影響を受ける行の数を自動的に返すことに注意してください。
//UPDATE Query:
$ affectedRows = App:: Query ()-> update ( ' users ' )-> set ([ " age " => 53 ,
" band " => " Metallica " ])
-> where ( ' username ' , ' = ' , ' jameshetfield ' )-> execute ();
//DELETE Query:
$ affectedRows = App:: Query ()-> deleteFrom ( ' users ' )-> where ( ' username ' , ' = ' , ' someone ' )-> execute ();クエリを削除または更新すると、条項が提供されていない場合、データが損失される可能性があることに注意してください。セキュリティ尺度として、DejFrameworkがそのような状況に遭遇した場合、例外をスローすることになります。接続クラスを手動で使用して、そのようなクエリを実行してください。
レイヤー3-オブジェクト関連マッピング: ORMについては、次のセクションで説明します。
ウィキペディアによると:
オブジェクトリレーショナルマッピング(ORM)...は、オブジェクト指向のプログラミング言語で互換性のないタイプシステム間でデータを変換するためのプログラミング手法です。これにより、実際には、プログラミング言語内から使用できる「仮想オブジェクトデータベース」が作成されます。
DejFrameworkはMVCアーキテクチャで機能するため、データの持続性はMVCのモデルコンポーネントに含まれています。モデルは、ショッピングシステム内のユーザー、購入、製品など、アプリケーションのエンティティに関連しています。データベースを保存して取得する必要があります。リレーショナルデータベースは、SQL言語で機能し、ほとんどのフレームワークと同様に、オブジェクト指向の環境で動作します。 PHPコードの途中のSQLコードは、ベストプラクティスではないと見なされます。したがって、DejFrameworkは3レベルのSQLコードからあなたを分離しようとします。そのうち2つが前のセクションで詳しく説明されました。これで、モデルの作業方法がわかります。
class User extends dej mvc Model
{
protected static $ dbTable = " users " ;
//Format: ["db_field_name" => "modelPropertyName"]
protected static $ primaryKey = [ " id " => " id " ];
//Model properties
public $ username ;
public $ password ;
public $ city ;
.
.
.
} class User extends dej mvc Model
{
protected static $ dbTable = " users " ;
//Format: ["db_field_name" => "modelPropertyName"]
protected static $ dbFields = [ " username " => " username " ,
" password " => " password " ,
" city " => " city " ,
" id " => " id " ];
public $ username ;
public $ password ;
public $ city ;
.
.
.
} idプロパティは、モデルが拡張する/dej/mvc/Modelクラスで定義されていることに注意してください。したがって、モデルをIDにしたい場合は、再度定義する必要はありません。
class User extends dej mvc Model
{
protected static $ dbTable = " users " ;
protected static $ dbFields = [ " username " => " username " ,
" password " => " password " ,
" city " => " city " ,
" id " => " id " ];
//Exactly the same as the class name
protected static $ modelName = " User " ;
public $ username ;
public $ password ;
public $ city ;
.
.
.
}これらの構成を正しく設定していれば、モデルでORMメソッドを使用できるようになった場合、これは今のところそれです。以下の例をご覧ください。
//Creating a new record
use app models User ;
$ user = new User ();
$ user -> username = " jameshetfield " ;
$ user -> password = " 13831383 " ;
$ user -> city = " Downey " ;
$ user -> create (); //Saved into the database.
//or you can set the properties in the constructor
$ user = new User ([
' username ' => ' jameshetfield ' ,
' password ' => ' 13831383 ' ,
' city ' => ' Downey '
]);
$ user -> create ();ORMは、下のDEJクエリビルダーを使用して、必要なクエリを生成します。
create()、update()、delete()は、操作が成功したかどうかを確認するために確認できる行を返すことができることに注意してください。
//Finding a record by a field named 'id'
$ user = User:: findById ( 11 );
//changing it's properties
$ user -> password = " through_the_never " ;
$ user -> update (); //Updated in the database.
//deleting it.
$ user -> delete ();これらの関数は、レコードの主要な鍵で動作することに注意してください。
//Finding records by some condition.
$ users = User:: find ()-> where ( ' city ' , ' = ' , ' Sari ' )-> getAll (); //Returns an array of User objects.
//A more complex one
$ users = User:: find ()-> where ( ' city ' , ' = ' , ' Sari ' )-> andWhere ( ' age ' , ' > ' , 20 )-> orderBy ( ' age ' , ' ASC ' )
-> limit ( 25 )
-> offset ( 100 )-> getAll ();
//Don't forget the get*() method!
//Retrieveing all records
$ users = User:: getAll (); //doesn't need a getAll() at the end because it knows what to do.
//The method for deleting by condition is named 'wipe'
$ users = User:: wipe ()-> where ( ' status ' , ' = ' , ' banned ' )-> orWhere ( ' email_confirmation ' , ' = ' , ' 0 ' )-> execute ();
//counting all records
$ userCount = User:: countAll ();
//counting records that have a certain condition
$ userCount = User:: count ()-> where ( ' city ' , ' = ' , ' Sari ' )-> getInt (); //getInt() returns the count of the results as an Integer.DejFrameworkのデータ検証はdejValidatorクラスによって処理されます。さまざまな方法で使用できます。
App::Validator()を使用して、アプリケーションのどこでも検証サービスを使用できます。これにより、Singletonインスタンスが表示されます。検証される値の2つのパラメーターを受け入れます。 (string、int、array、object)およびデータを検証するための一連のルール。それがどのように機能するか見てみましょう:
use dej App ;
//Validate a single value according to a set of rules seperated by "|".
$ result = App:: Validator ()-> validate ( " This is going to be validated " , " required|string|min:5|max:30 " );
//Validate an object or and array:
$ result = App:: Validator ()-> validate ( $ user , [ ' username ' => ' required|string|email|min:5|max:30 ' ,
' password ' => ' required|string|min:10|max:100 ' ],
' age ' => ' int|min:18|max:99 ' ); validate()メソッドは配列を返します。検証エラーがなく、データが有効な場合、空の配列になります。したがって、データがempty()で有効かどうかを確認できます。検証エラーがある場合は、配列に表示されます。
//The rules have changed
$ errors = App:: Validator ()-> validate ( " This is going to be validated " , " required|string|email|min:5|max:10 " );
var_dump ( $ errors );これは、上記のコードが出力するものです。
array
0 => 'This Field should be an email'
1 => 'This Field should be less than 10'
今オブジェクトを使用して:
$ errors = App:: Validator ()-> validate ( $ obj , [ ' email ' => ' required|string|email ' ,
' password ' => ' required|string ' ,
' age ' => ' int ' ]);
var_dump ( $ errors );出力:
array (size=3)
'email' =>
array (size=1)
0 => string 'This Field should be an email'
'password' =>
array (size=2)
0 => string 'This Field is Required'
1 => string 'This Field should be more than 10'
'age' =>
array (size=1)
0 => string 'This Field should be a number'
ご覧のとおり、オブジェクトまたは配列をバリデーターに渡すと、キーがフィールド名であり、値がそのフィールドに関連するエラーを含む配列である連想配列の各フィールドに関連するエラーを返します。
validate()メソッドを使用して、リクエストパラメーター(get&postパラメーター)を検証できます。 $ errors = App:: Request ()-> validate ([ ' email ' => ' required|string|email ' ,
' password ' => ' required|string|min:10|max:100 ' ]);
var_dump ( $ errors ); yoursite.local/?email=notanemail&password=123にアクセスしてください。
array (size=2)
'email' =>
array (size=1)
0 => string 'This Field should be an email'
'password' =>
array (size=1)
0 => string 'This Field should be more than 10'
/app/models/User.php models/user.phpに含まれるユーザーモデルを参照してください。 class User extends dej mvc Model
{
.
.
.
protected static $ validationRules = [ " username " => " required|string|min:5|max:20 " ,
" password " => " required|string|min:5|max:255 " ,
" city " => " string|max:10 " ];
.
.
.
}これで、モデルのインスタンスを検証できます。
$ user = User:: getById ( 11 );
$ errors = $ user -> validate (); //returns errors in array like the previous examples.
$ isValid = $ user -> isValid (); //returns true or falseエラーが発生したら、ビューに渡して表示したり、どこかにリダイレクトしたりできます。
//in the controller
$ errors = $ user -> validate ();
if (! empty ( $ errors )) return App:: Response ()-> redirect ( ' / ' )-> withErrors ( $ errors );前の例で見た検証メッセージは、デフォルトのメッセージであり、それらを変更したい場合、または自分の言語に検証メッセージを持っている場合はどうなりますか? /app/locale/en/validation/messages.phpをご覧ください。
return [
" required " => " This Field is Required " ,
" string " => " This Field should be an string " ,
" int " => " This Field should be a number " ,
" min " => " This Field should be more than %s " ,
" max " => " This Field should be less than %s " ,
" email " => " This Field should be an email " ,
];キーは検証型に対応し、値は検証メッセージであることがわかります。変数は、「S」のメッセージに含まれています。 /app/localeでは、選択の言語用の独自のディレクトリを作成できます。そのディレクトリには、変数を使用した独自の検証メッセージを作成できます。
/config.jsonでデフォルトのロケールを設定できます。
App::Config()->locale = 'your_locale';
PHPセッションで作業するために、dejframeworkはdejSessionクラスを提供します。使用方法に関するいくつかの例を次に示します。
//to set session variables
App:: Session ()-> save ([
' key1 ' => ' value1 ' ,
' key2 ' => ' value2 '
]);
//to get session variables
$ value1 = App:: Session ()-> get ( ' key1 ' );
//to regenerate session id
App:: session ()-> regenerateId ();
//get all session variables as associative array
$ wholeSession = App:: session ()-> all ();
//destroy the session
App:: session ()-> destroy ();
//delete a variable
App:: session ()-> delete ( ' key1 ' );
//see if variable is set
$ trueOrFalse = App:: session ()-> isSaved ( ' key1 ' );次のリクエスト、たとえば特定のエラーメッセージでのみセッション変数を使用できるようにする場合は、次のようなセッションにフラッシュできます。
App:: session ()-> flash ([ ' message ' => ' Registered Successfully! ' ]);次のリクエストで取得します。
$ message = App:: session ()-> getFlash ( ' message ' );フラッシュメッセージは次のリクエストでのみ利用可能であり、 ->getFlash()でのみ使用できます。
セッションへの最後のアクセスから定義された時間の後に期限切れにセッションを設定できます。
App:: Session ()-> save ([ ' key ' => ' value ' ]);
App:: Session ()-> lifeTime ( 60 ); //session will expire after 60 seconds since last access to the session. (last use of App::Session())次のリクエストのモデルのインスタンスをアプリケーションに覚えておくことができる場合があります。たとえば、ログインしているユーザー、ユーザーが持っているショッピングカートなど、アプリに覚えておいてください。セッションで希望するモデルの主要なキーを保存し、すべてのリクエストでそれを取得するためにクエリを実行すると、退屈になる可能性があります。 DejFrameworkは、モデルで使用できる特性を提供することでこれを解決します。見てください:
class ShoppingCart extends dej mvc Model
{
use dej traits IsStateful;
.
.
.
}これで、モデルにはさらにいくつかの方法があります。
//suppose you want to create a shopping cart for a guest user and add a product to it:
$ cart = new ShoppingCart ();
$ cart -> addProduct ( 2389 );
$ cart -> create (); //stored in the db
//if you want to save it to the session get it easily in the next request
$ cart -> remember ( ' guest_shopping_cart ' ); //provide a key to remember it by this key.次のリクエストで:
if (ShoppingCart:: isRemembered ( ' guest_shopping_cart ' )) //see if theres any cart in the session
$ cart = ShoppingCart:: retrieve ( ' users_shopping_cart ' ); //get's fresh data from the db
if (ShoppingCart:: hasChanged ( ' guest_shopping_cart ' ))
{
//checks if the cart in the database has changed **since you saved the cart in the session**.
doSomeThing ();
}
ShoppingCart:: forget ( ' guest_shopping_cart ' ); //forgets the cart.ユーザーにデータを提示するには、ユーザーインターフェイスが必要です。ウェブでは、ほとんどの場合、これはHTMLマークアップを意味します。 MVCでは、ロジックをUIから分離する必要があるため、HTMLをビューに配置し、値をechoする、アレイを「foreach」に配置するなど、プレゼンテーションロジックのみを含めます。ビューを作成するには:
/app/viewsでビューファイルを作成します。デフォルトに含まれるビューが1つあります: index.phtml <!DOCTYPE html >
< html >
< head >
< title > < ?= $data- > user- > username ? > 's profile </ title >
</ head >
< body >
< h2 > View < ?= $data- > user- > username ? > 's Profile </ h2 >
< p > Username: < ?= $data- > user- > username ? > </ p >
< p > Password: < ?= $data- > user- > password ? > </ p >
< p > City: < ?= $data- > user- > city ? > </ p >
</ body >
</ html > class IndexController extends dej mvc Controller
{
public static function index()
{
$ user = User:: find ()-> where ( ' username ' , ' = ' , ' jameshetfield ' )-> getOne ();
return App:: View ( ' user ' , [ ' user ' => $ user ]); //the first argument is the view name,
the second one is the data you want to pass to
the view, in this example, a variable called ' user '
will be available in the user.phtml view
which contains the instance of user we fetched.
Piece of cake!
}
}エラーメッセージも提供できます。
//in the controller
return App:: View ( ' user ' )-> withErrors ([ ' authorization ' => ' You are not allowed to view this user. ' ]);フレームワークはビューを出力にレンダリングし、結果は次のとおりです。
<!DOCTYPE html >
< html >
< head >
< title > jameshetfield's profile </ title >
</ head >
< body >
<!-- access the errors like this: -->
< span class =" error " > < ?= $this- > errors('authorization') ? > </ span >
< h2 > View jameshetfield's Profile </ h2 >
< p > Username: jameshetfield </ p >
< p > Password: 13831383 </ p >
< p > City: Downey </ p >
</ body >
</ html >それでは、別の例を見てみましょう。すべてのユーザーのテーブルを作成したい場合はどうなりますか?あなたのビューを編集します:
<!DOCTYPE html >
< html >
< head >
< title > All Users </ title >
</ head >
< body >
< table >
< tr >
< th > username </ th >
< th > password </ th >
< th > city </ th >
</ tr >
< ?php foreach ($data- > users as $user): ? >
< tr >
< th > < ?= $user- > username ? > </ th >
< th > < ?= $user- > password ? > </ th >
< th > < ?= $user- > city ? > </ th >
</ tr >
< ?php endforeach; ? >
</ table >
</ body >
</ html >そして、あなたのコントローラー:
class IndexController extends dej mvc Controller
{
public static function index ()
{
$ users = User:: getAll ();
return App:: View ( ' user ' , [ ' users ' => $ users ]);
}
}そして、あなた自身のために結果を見てください!
部分的なビューを作成して、他のビューに貼り付けます(含める)ことができます。
[/app/views/partials/header.phtml]
<!--begin header-->
<!DOCTYPE html >
< html >
< head >
< meta charset =" UTF-8 " >
< title > < ?= $data- > title ? > </ title >
</ head >
< body >
<!--end header--> index.phtmlに貼り付けます:
[/app/views/index.phtml]
< ?php $this- > paste('partials/header'); ? >
< h2 > < ?= $data- > message ? > </ h2 >
.
.
.
</ html >認証はアプリケーション関連の問題です。すべてのアプリケーションで非常に異なる可能性があるため、DeJFrameworkはフレームワーク自体に実装しません。代わりに、基本的なユーザーモデル、認証を実現するIsStatefulルート、コントローラーロジックが提供さ$user->remember() 、自由に変更できます。必要な唯一のことは、 config.jsonで'default_auth_model'を設定して、 IsStateful特性を使用してセッションからユーザーを::retrieve()ためにApp::Request->user()を使用できるようにすることです。
認証のためのフレームワークで提供されているコントローラー、モデル、およびビューを確認して、その動作を理解してください。そして、あなたが好きなようにそれを変更/改善/削除します。
注:ユーザーモデルが正しく動作するには、2つのフィールドを持つusersという名前のテーブルを作成する必要があります。
TABLE: users
FIELD TYPE
id int, autoincrement
username varchar
password varchar(255) //password hashing system requires 255