Janggelan은 예상치 못한 PHP 프레임 워크입니다. 간단하지만 강력하며 사용하기가 즐겁습니다. 다른 프레임 워크와 마찬가지로 Janggelan을 이해하려고 할 때는 어려움이 없습니다.
Janggelan은 MVC 개념을 기반으로 설계되었으며 초점을 맞추고 있습니다. 따라서 우리는 MVC 시스템을 성능을 줄일 수 있기 때문에 개발에 도움이 될 수있는 다른 도구와 병합하지 않으려 고 노력합니다. 우리는 물론 당신의 개발을 돕기 위해 그것을 계속 동봉하지만, 다른 표지와 함께 제공 될 것입니다.
자세한 내용은 문서를 읽으십시오.
우리는이 프레임 워크를 완벽하게 완성 할 수 없으며 아마도 당신이 원하는 것과 일치하지 않을 수도 있습니다. 그러나 우리는 항상 그것을 더 잘 마치고 당신을 위해 예상치 못한 것을 만들려고 노력합니다. 당신은 우리와 함께 기여할 수 있습니다.
몇 가지 새로운 도구가 추가되었습니다.
새로운 더 나은 성능을 위해 모든 Janggelan의 스크립트를 다시 작성했습니다.
서버로드를 줄입니다.
몇 가지 새로운 Model 방법을 추가했습니다 : where() , exec() , execute() .
추가 문서.
.htaccess 에서 캐싱 및 압축 gZip 사용했습니다.
PHP 7
PDO PHP 확장
Janggelan의 파일을 다운로드하여 응용 프로그램 디렉토리로 추출하십시오.
공유 호스팅을 위해 Janggelan을 게시하거나 설치하려면 가장 안전한 방법은 Janggelan의 파일 및 디렉토리를 server root 내부에 배치하고 public 폴더의 모든 내용을 public_html 또는 www 로 옮겼습니다.
public / public_html / www 디렉토리에서 응용 프로그램을 실행합니다.
설치 후 문제를 발견 한 경우 파일 권한을 확인하십시오.
__ backend/
|__ .secrets/
|__ config/
|__ framework/
|__ global/
|__ register/
|__ vendor/
|__ autoload.php
|__ composer.json
|__ force.uri
__ public/
|__ assets/
|__ .htaccess
|__ index.php
__ worksheet/
|__ controllers/
|__ model/
|__ providers/
|__ tools/
|__ views/
|__ requests.php
처음으로 서버에서 Janggelan을 실행하겠습니다. 시스템이 System Requirements 과 위의 installation 수행했는지 확인하십시오.
Janggelan 파일이 배치 된 응용 프로그램 디렉토리로 이동하십시오. public 폴더에 입력하십시오. 예를 들어, Linux에서는 다음을 수행 할 수 있습니다.
cd /var/www/html/your_application/public로컬 호스트 서버 열기 :
php -S localhost:8000또는이 명령으로 위의 직접 수행 할 수 있습니다.
php -S localhost:8000 -t /var/www/html/your_application/public이제 브라우저를 열고 LocalHost : 8000을 방문하십시오.
Janggelan에서는 이것을 requests 으로 부릅니다. Laravel과 같은 다른 PHP 프레임 워크에서는 routes 라고합니다. Janggelan의 모든 요청은 파일 worksheet/requests.php 에서 처리했습니다. 새 요청을 만들려면 해당 파일로 이동하십시오. 다음과 같은 request 예제가 표시됩니다.
$ this -> request ( ' GET / @Hello::world ' ); 위의 예는 GET 과 같습니다. "요청 메소드가있는 요청 URI / 와 함께 사용자 방문 / 와 URI가 유효한 경우 메소드 / 기능 world 사용하여 Hello 로 진행됩니다." 예제에 따라 이제 다음 옵션으로 사용자 정의 요청을 만들 수 있습니다. (인수 또는 매개 변수 1은 space 별로 분리됩니다) :
// Redirected to Controller.
// Request method can be 'GET' or 'POST'
$ this -> request ( ' GET /home @Hello::world ' );
// Redirected to View.
$ this -> request ( ' GET /home (viewName) ' );
// Redirected to Controller with Protected Rule 'login'.
$ this -> request ( ' GET /home @Hello::world !!login ' );
// Redirected to View with Protected Rule 'login'.
$ this -> request ( ' GET /home (viewName) !!login ' );
// Will proceed the Closure or Callback directly.
$ this -> request ( ' GET /home ' , function ()
{
// Do some stuff...
});
// Will proceed the Closure or Callback directly with Protected Rule 'login'.
$ this -> request ( ' GET /home !!login ' , function ()
{
// Do some stuff...
}); 나중에 Protected Rule 에 대해 더 많이 배울 것입니다. 테스트 중일 때만 Closure 또는 Callback 사용하십시오. 우리는 항상 View 또는 Controller 리디렉션으로 사용하는 것이 좋습니다.
Controller 는 worksheet/controllers 에 배치됩니다. 파일 이름이 MyController.php 라고 가정하면 새 파일을 작성하여 새 Controller 작성하십시오. 그런 다음 MyController.php 에서이 기본 Controller 스타일을 작성하십시오.
<?php namespace controller ;
class MyController extends framework parents Controller
{
public function welcome ()
{
echo ' Welcome to my Controller. ' ;
}
} worksheet/requests.php 에서 Controller 진행할 새 요청을 추가하십시오.
$ this -> request ( ' GET /test @MyController::welcome ' ); 이제 브라우저를 방문 /test . 모든 것이 정상이라면 출력 : Welcome to my Controller. . Controller 파일 이름은 동일하고 Controller 클래스 이름과 일치해야합니다. 또한 Namespace 에주의를 기울여야합니다. 다음과 같은 새 디렉토리 안에 컨트롤러를 작성하는 경우 :
__ controllers/
|__ my_new_folder/
|__ MyController.php
그런 다음 Controller 의 Namespace 다음과 같아야합니다. (이것은 모든 네임 스페이스 시스템에도 적용됩니다).
<?php namespace controllers my_new_folder ;
class MyController extends framework parents Controller
{
//
} Controller $this->LOAD_VIEW() , $this->GET_RULE() 등과 같은 내장 된 기능을 사용하지 않아도 frameworkparentsController 확장하지 않을 수 있습니다.
Model S는 worksheet/models 에 배치됩니다. Model 데이터베이스와 통신하는 데 사용됩니다. 따라서 Model 만들 때 데이터베이스의 데이터와 해당하는지 확인하십시오. Model 사용하려면 backend/.secrets/.db 에서 데이터베이스 구성을 설정하거나 Configuring Database 에 대한 설명서를 참조해야합니다.
위의 완료 후 Model 만들어 보자. 먼저 worksheet/models 로 새 파일을 만듭니다. 파일 이름이 User.php 라고 가정합니다. 그런 다음이 기본 Model 스타일로 파일의 내용을 작성하십시오.
<?php namespace model ;
class User extends framework parents Model
{
// This is your table name. It is required by system.
protected static $ table = ' user ' ;
// This is your table columns. Only required if you want to create new
// table into Database.
protected static $ columns = [
' id ' => ' INT(11) AUTO_INCREMENT PRIMARY KEY ' ,
' username ' => ' VARCHAR(255) NOT NULL ' ,
' password ' => ' VARCHAR(255) NOT NULL '
];
} Controller 에서 Model 클래스를 호출하십시오.
<?php namespace controller ;
use model User ;
class MyController extends framework parents Controller
{
public function workingWithModel ()
{
// Initialize object of Model 'User'.
// Now you can use your Model.
$ user = new User ;
}
} 이전에 이름 user 있는 테이블이없는 경우 create() 메소드를 사용하여 Controller 메소드를 실행할 때 테이블을 자동으로 작성 workingWithModel() .
$ user = new User ;
// this will create new table into Database with columns and properties that
// already defined on 'protected static $columns'.
$ user -> create (); 거의 완료되면 이제 내장 기능이나 방법으로 Model 사용해야했습니다.
$ user = new User ;
// Open Database connection manually. Only needed if 'auto_connect' config is FALSE.
$ user -> open ();
// Close Database connection manually. Only needed if 'auto_connect' config is FALSE.
$ user -> close ();
// Delete all data in Model 'User' | table 'user'.
$ user -> delete ();
// Delete all data in Model 'User' | table 'user' | where id = 1 and username = name.
$ user -> delete ([ ' id ' => 1 , ' username ' => ' name ' ]);
// Insert new data to Model 'User' | table 'user' | to column username with value
// 'Linus Torvald'.
$ user -> insert ([ ' username ' => ' Linus Torvald ' ]);
// Update data in Model 'User' | table 'user' | where id = 1. Update username
// to value 'Linus Torvald'.
$ user -> update ([ ' username ' => ' Linus Torvald ' ], [ ' id ' => 1 ]);
// Get all data from Model 'User' | table 'user'.
$ user -> get ();
// Get 5 data results from Model 'User' | table 'user'.
$ user -> get ( 5 );
// Select all data from column 'username' of Model 'User' | table 'user'.
$ user -> select ( ' username ' )-> get ();
// Get data from column 'username' of Model 'User' | table 'user' | take 4 data results
// start from data number 2.
$ user -> range ( 4 , 2 )-> get ();
// Get data from Model 'User' | table 'user' | based on the clause 'WHERE id = 1'.
// You can do anything inside of 'clause()'.
$ user -> clause ( ' WHERE id = 1 ' )-> get ();
// Select data from column 'username' of Model 'User' | table 'user' |
// where id = 1 AND username = 'Linus Torvald'.
$ user -> where ([ ' id ' => 1 , ' username ' => ' Linus Torvald ' ])-> get ();
// Exec query.
// 'query' is anything sql queries such as 'DELETE * FROM' or 'SELECT *'.
$ user -> exec (query);
// Execute query with bind params (PDO prepare statement).
$ user -> execute (query, bindParams);
// You can custom you queries with chaining functions or methods like this:
$ user -> select ( ' username ' )-> range ( 4 , 2 )-> get ();
// Using prepare statement
$ user -> clause ( ' WHERE id=:id ' )-> bindParams ([ ' id ' => 1 ])-> get (); View S는 worksheet/views 에 배치됩니다. 기본적으로 View 는 템플릿이며 HTML 또는 PHP 코드 일 수 있습니다. View 위한 특별한 규칙은 없습니다. 그러나 Janggelan에서 View Extension은 항상 .php 입니다. View 내부에 코드를 쓸 수 있습니다. View 사용하려면 전화하면됩니다. 예:
// Calling View 'example.php' on requests.php
// Note that you cannot calling View with Closure or Callback.
$ this -> request ( ' GET / (example) ' );
// Calling View 'example.php' inside folder 'new_folder' on requests.php
$ this -> request ( ' GET / (new_folder/example) ' );
// Calling View 'example.php' on Controller
$ this -> LOAD_VIEW ( ' example ' );
// Calling View 'example.php' inside folder 'new_folder' on Controller
$ this -> LOAD_VIEW ( ' new_folder/example ' ); public 또는 public_html 또는 www 디렉토리의 모든 곳으로 워크 View worksheet/views 볼 수 있으려면 / : 만 추가하면됩니다.
$ this -> request ( ' GET / (/example) ' );
$ this -> LOAD_VIEW ( ' /example ' ); 이는 시스템에 public/example.php 또는 public_html/example.php 또는 www/example.php 에 View 찾도록 지시합니다.
이제 데이터를 View 하는 방법. 실제로 간단하게 할 수 있습니다. 단지 compact() 데이터 : Controller 가 View 호출 할 때만 데이터를 전달할 수 있습니다.
$ data = ' This is data ' ;
$ this -> LOAD_VIEW ( ' example ' , compact ( ' data ' )); 그런 다음 View 파일 example.php 에서 변수를 호출합니다.
<p> <?php echo $ data ; ?> </p> Janggelan은 사용할 수있는 몇 가지 도구를 제공하고 개발 사례에 유용 할 수 있습니다. 그들은 worksheet/tools 에 배치됩니다. 그것들을 사용하려면 클래스 이름을 부르면됩니다. 예:
<?php namespace controller ;
use tool Validation ;
class Example extends framework parents Controller
{
private $ validation ;
function __construct ()
{
$ this -> validation = new Validation ;
}
} Protected Rule 은 로그인 시스템과 마찬가지로 page , View 또는 Uri 를 보호하기위한 Janggelan의 시스템입니다. Protected Rule request 시스템을 사용할 때 항상 점검 해야하는 익명 데이터를 저장했습니다. 방문에 유효한 익명 데이터가없는 경우 사용자는 이전에 정의 된 target 으로 자동으로 리디렉션됩니다. 이렇게하면 개인을 비공개로 만들거나 특정 사용자에게만 페이지를 보호 할 수 있습니다.
새 Protected Rule 만들려면 backend/config/protected.php 의 구성 파일로 이동하십시오. 하나 이상의 Protected Rule 만들 수 있습니다. 예:
<?php return [
// FALSE means, system will uses SESSION to store protected_rule data. Set it TRUE
// if you want to store the data in COOKIE.
' use_cookie ' => FALSE ,
' protected_rule ' => [
// Creating 'Protected Rule' with name 'login'.
// If the data is not valid, then redirect to Controller 'Example'
// method 'protected.'
' login ' => [
' on_false ' => [
' controller ' => ' Example ' ,
' method ' => ' protected '
],
],
// Creating 'Protected Rule' with name 'protect'.
// If the data is not valid, then redirect to View 'example'.
' protect ' => [
' on_false ' => [
' view ' => ' example ' ,
],
],
// Creating 'Protected Rule' with name 'myRule'.
// If the data is not valid, then redirect to uri '/wrong'.
' myRule ' => [
' on_false ' => ' /wrong '
],
]
]; 그런 다음 해당 Protected Rule 적용하려면 worksheet/requests.php 로 이동하여 새 Request 추가하십시오. (구문은 !! ) :
// Applying Protected Rule 'login'.
$ this -> request ( ' GET / @Example::example !!login ' );
$ this -> request ( ' GET / (viewName) !!login ' );
$ this -> request ( ' GET / !!login ' , function ()
{
echo ' If you see this, then you are an Admin. ' ;
}); 사용자 또는 Protected Rule 에 대한 유효한 데이터를 설정하는 방법은 무엇입니까? 이 내장 기능 또는 방법을 사용하십시오.
$ this -> SET_RULE ( $ name ); 값을 Protected Rule 데이터로 전달할 수도 있습니다.
$ this -> SET_RULE ( $ name , $ values ); 다음은 Protected Rule 위한 완전한 기능 또는 방법입니다.
// Check valid data for user or 'Protected Rule';
$ this -> CHECK_RULE ( $ name );
// Set new valid data for user or 'Protected Rule'.
$ this -> SET_RULE ( $ name , $ data = '' );
// Get 'Protected Rule' data.
$ this -> GET_RULE ( $ name );
// Delete valid 'Protected Rule' data.
$ this -> DESTROY_RULE ( $ name ); 데이터베이스를 구성하려면 backend/.secrets/.db 로 이동하십시오. 데이터베이스를 구성 할 객체가 포함되어 있습니다.
{ "DB_HOST" : " " , "DB_NAME" : " " , "DB_USERNAME" : " " , "DB_PASSWORD" : " " }데이터베이스 구성으로 모든 키 값을 설정하십시오.
기본적으로 Janggelan은 디렉토리에 대한 URI로 유효합니다. URI가 ISSET 폴더 또는 디렉토리를 참조하는 경우 Janggelan 시스템은 해당 폴더 또는 디렉토리로 리디렉션되기 때문에 시작되지 않습니다. 이 일이 일어나지 않으려면 파일 backend/force.uri 열고 오래된 값을 TRUE 로 다시 작성하십시오.
달리 케와라 | [email protected]
Janggelan은 MIT 라이센스에 따라 라이센스가 부여 된 오픈 소스 PHP 프레임 워크입니다.