Lazymephp는 작고 배우기 쉽고 배우기/사용하기 쉬운 PHP 프레임 워크입니다.
Lazymeph의 아이디어는 내가 게으르기를 허용하는 것입니다. 따라서 그 과제를 돕기 위해서는 테이블과 관계가있는 적절한 데이터베이스를 설정하면됩니다.
유일한 제한 사항은 각 테이블에 기본 키가 있어야한다는 것 입니다.
데이터베이스의 구조를 변경 해야하는 경우 (추가/제거 된 열, 무엇이든) 언제든지 모든 코드를 재생할 수 있습니다 (일부 예방 조치).
git clone https://github.com/Peixinho/LazyMePHP myAwesomeProject
#optional, but I advise to start your own git repository, for many reasons...
cd myAwesomeProject && rm -rf .git
cd src/Ext
composer update (to get dependencies)
# run initial config
php LazyMePHP config
이제 초기 구성자를 명령 줄에서 실행하여 다음 항목을 채워야합니다.
다음으로, 당신은 달릴 수 있습니다
php LazyMePHP build
초기 생성 후이 도구를 실행하고 생성 된 양식, API 또는 클래스를 변경 한 경우 (어쨌든 생성 된 클래스를 변경해서는 안됩니다) 변경 사항이 손실 될 수 있습니다.이 도구는 테이블 기반이므로 특정 테이블 양식 또는 API를 변경하면 선택하지 마십시오.
그 후에는 구축 할 내용 및 기타 옵션을 선택할 수있는 데이터베이스 테이블 목록이 있습니다. -d : 테이블 설명자 -C : C : 빌드 클래스 -F : 빌드 양식 -A : a : a : a : 이후 로그를 활성화하면 모든 테이블을 나열하거나 'a'를 선택하거나 선택할 수 있습니다. 이것은 모든 클래스, 양식 및 API에 대해 동일합니다.
모든 것이 잘 진행되면 기본 기능을 갖춘 작업 색인이 있습니다.
php LazyMePHP serve
그리고 탐색
http://localhost:8080
| 사용자 |
|---|
| PK ID |
| FK Countryid |
| 이름 |
| 나이 |
| 국가 |
|---|
| PK Countryid |
| CountryName |
pk country.countryId-> fk user.countryId가 있습니다
생성 된 모든 테이블에는 다음과 같이 작동하는 양식이 있습니다.
## Classes
Every table generated will have a class that works as follows:
- Each Table will have a Class File by default in /src/Classes/[Table Name].php
- All Classes will be in namespace LazyMePHPClasses
- All Class columns have getters and setters *Get*[Column Name], *Set*[Column Name]
- All Classes have Save method, if Id is provided when constructing object:
```
$user = new User(); $user->Save(); // Will act as an INSERT
...
$user = new User(123); $user->Save(); // Will act as an UPDATE
```
-All classes have a Delete method, if id was provided upon constructing object
- Foreign members can be built automatically
```
// Country
$pt = new LazyMePHPClassesCountry();
$pt->SetCountryName('Portugal');
$pt->Save();
// User
$user = new LazyMePHPClassesUser();
$user->SetName('Peter');
$user->SetAge('30');
$user->SetCountryId($pt->Getid());
$user->Save();
echo $user->GetId(); // e.g. 123 - id is the primary key in User Table
// Retrieving user data and changing it
$user = new LazyMePHPClassesUser(123);
echo $user->GetName(); // 'Peter'
$user->Setname('John');
$user->Save();
// Access Foreign members by uing Get[Column Name]Object
echo $user->GetCountryIdObject()->GetCountryName();
// And changing it
$user->GetCountryIdObject()->SetCountry('England'); // Of course, you are changing Country Name in Country Table
$user->GetCountryIdObject()->Save();
# Not building Foreign members
$user = new LazyMePHPClassesUser(5, false); // this won't query foreign tables
```
- Every class will have a *table*_list class, that allows you to select a list of that class type
- Every List have a *FindBy*[Foreign Column Name], *FindBy*[Foreign Column Name]*Like*, *OrderBy*[Foreign Column name], *GroupBy*[Foreign Column], *Limit*
```
$users = new LazyMePHPClassesUser_List();
$users->FindByNameLike('John');
$users->OrderByAge();
// As in regular classes, you can or not build foreign tables, by default is building them
foreach($users->GetList() as $u) { echo $u->GetName(); echo $u->GetCountryIdObject()->GetCountryName(); }
// Not building foreign members
foreach($users->GetList(false) as $u) ...
```
## API
Every table generated will have some routes created in src/api/RouteAPI.php, and they make use of the controllers of each table
- Accessible from /api/[Table Name]/ (.htaccess for apache, didnt bother with others)
http : // localhost : 8080/api/user/ #은 모든 사용자 정보를 JSON 형식으로 출력합니다.
http : // localhost : 8080/api/user/? findbynamelike = john & limit = 10 # 기준과 제한과 일치하는 JSON 형식으로 모든 사용자 정보를 출력합니다.
http : // localhost : 8080/api/user/123 # json 형식의 사용자 123 정보를 출력합니다.
그래, 그게 사실이야! 그러나 파일을 편집하여 원하는 열 (기본적으로) 만 노출하도록 구성 할 수 있습니다.
/api/src/RouteAPI.php
그것은 유틸리티에 의해 생성됩니다. 각 테이블의 경우 해당 파일에 열의 배열이 생성되고 하드 코딩되며, 열 이름이 해당 배열 내부에 있으면 데이터가 표시되지 않으며 그렇지 않으면 BTW는 Lazymephp의 책임이 아닙니다.
이 옵션이 활성화되면 데이터베이스에 변경된 모든 변경 사항을 등록하는 데이터베이스에 3 개의 테이블이 추가됩니다. 수행 해야하는 유일한 구성은 편집하는 것입니다.
/src/Configuration/Configurations.php
데이터베이스 변경의 소유자로 등록 할 사용자 인증을 정의합니다.
// ACTIVITY LOG
$CONFIG['APP_ACTIVITY_LOG']=1;
$CONFIG['APP_ACTIVITY_AUTH']=$_SESSION['user_logged'];
뷰어가 /로깅 중이며 날짜 DESC에서 주문한 요청 목록을 표시하며 사용할 수있는 필터가 있습니다. 이것은 전체 특집 시청자가 아니며 확장 할 예로 볼 수 있습니다 (그러나 잘 작동합니다).
MIT