# Shani Web Application Framework
Shani는 성능, 보안, 창의성 및 최신 웹 응용 프로그램 개발 관행이 공존하는 동안 최소한의 노력으로 빠른 응용 프로그램 개발을 가능하게하도록 설계된 오픈 소스 웹 프레임 워크입니다.
Shani를 사용하여 실용 측 또는 서버 측 애플리케이션을 구축하십시오. Shani는 백엔드에 서 있거나 그 반대의 경우에 좋아하는 프론트 엔드 프레임 워크를 사용할 수도 있습니다.
Shani는 Linux 및 Mac OS에서 잘 작동하지만 Windows 사용자의 경우 Linux (WSL) 용 Windows 서브 시스템을 사용할 수 있습니다.
설치가 필요하지 않습니다.
Shani Application Web Server를 시작하려면 터미널에서 다음 명령을 실행하십시오.
$ php index.phpShani Application에는 다음과 같은 프로젝트 구조가 있습니다
/root
apps/ (Contains user applications. Create your applications here)
config/ (Contains important server and hosts configurations)
hosts/ (Contains host configurations files (hostname.yml). Register your application here)
localhost.yml (can be customized)
ssl/ (Contains server ssl certificate files for)
mime.yml
server.yml (Server configuration are written here, and can be customized.)
gui/ (Contains support for GUI building)
assets/ (Contains static files e.g: .css, .js,fonts etc shared by all applications)
html/ (Contains html templates comes with framework)
library/ (Contains files comes with framework that can be used directly by user application)
shani/ (Contains core framework files)
index.php (The entry point of a Shani application)
일반적인 사용자 애플리케이션 폴더 구조는 다음과 같이 나타날 수 있습니다.
apps/
demo/
v1/
modules/ (Can be renamed)
module1_name/ (Can be desired module name)
src/ (Can be renamed)
get/ (This is the request method as directory)
Resource.php (Can be any resource file)
views/ (can be renamed)
resource/ (All lowercase, must match resource file name)
lang/ (Can be renamed)
resource/ (All lowercase, must match resource file name)
breadcrumb/(Can be renamed)
resource/ (All lowercase, must match resource file name)
functions/ (can be renamed)
function-name.php (Must match function name in resource file class)
resource.php (must match module name)
module1_name.php (must match module name)
버전 1.0 ( v1 )을 갖는 demo 라는 응용 프로그램을 작성한다고 가정 해 봅시다. 우리의 응용 프로그램에는 greetings 라는 하나의 모듈과 Hello.php 라는 리소스 파일 하나가 있습니다.
이제 리소스 파일의 다음 예를보십시오.
<?php
namespace apps demo v1 modules greetings web get {
use shani engine http App ;
final class Hello
{
private App $ app ;
public function __construct ( App & $ app )
{
$ this -> app = $ app ;
}
/**
* Display greetings from Shani.
*/
public function world ()
{
//sending output to user agent using default view file (world.php)
$ this -> app -> render ();
}
}
} 보기 파일 만들기 : ( apps/demo/v1/modules/greetings/views/hello/world.php )
<h1>Hello From Shani</h1>위의 예를 고려할 때 응용 프로그램 폴더 구조는 다음과 같습니다.
apps/
demo/
v1/
modules/
greetings/
src/
get/
Hello.php
views/
hello/
world.php
다음 단계는 웹에서 사용할 수 있도록 응용 프로그램을 등록하는 것입니다. /config/hosts/ 로 이동하여 localhost.yml 이라는 구성 파일을 만들어이를 수행 할 수 있습니다. 이름을 선택할 수 있습니다.
기억하다! 각 응용 프로그램에는 자체 구성 파일이 있어야합니다
다음은 Shani 와 함께 제공되는 기본 응용 프로그램 구성입니다.
# A user application must have atleast one version.
VERSIONS :
" 1.0 " :
# Environment variables are customs, you can create any e.g DEV, TEST, PROD or any
# Must extends shaniadvisorsConfiguration
ENVIRONMENTS :
DEV : appsdemov1configSettings
# Active environment can any one of the provided above.
ACTIVE_ENVIRONMENT : DEV
DEFAULT_LANGUAGE : sw
# Whether an application is running or not
RUNNING : true
" 2.0 " :
ENVIRONMENTS :
DEV : appsdemov2configSettings
ACTIVE_ENVIRONMENT : DEV
DEFAULT_LANGUAGE : sw
RUNNING : true
# The default application version
DEFAULT_VERSION : " 2.0 "응용 프로그램 요구에 맞게이 파일을 사용자 정의하겠습니다.
VERSIONS :
" 1.0 " :
ENVIRONMENTS :
DEV : appsdemov1configDevSettings
TEST : appsdemov1configTestSettings
PROD : appsdemov1configProdSettings
ACTIVE_ENVIRONMENT : DEV
DEFAULT_LANGUAGE : sw
RUNNING : true
DEFAULT_VERSION : " 1.0 " 다음 단계는 이러한 구성 클래스 파일을 만드는 것입니다. apps/demo/v1/config/ 아래에서 만들 것입니다. 일부 콘텐츠는 그렇습니다.
<php
namespace apps demo v1 config {
use shani advisors Configuration ;
use shani engine http App ;
final class DevSettings extends Configuration
{
public function __construct ( App & $ app , array & $ configurations )
{
parent :: __construct ( $ app , $ configurations );
}
//Add all unimplemented methods here
}
} http://localhost:8008 통해 응용 프로그램을 사용할 수 있다고 가정 해 봅시다. 또한 http://127.0.0.1:8008 및 http://example.local 등을 통해 응용 프로그램을 사용할 수 있기를 원합니다.
별칭의 개념이 제공되며, 응용 프로그램이 둘 이상의 호스트 이름을 통해 사용할 수있는 경우입니다. localhost.yml 파일을 만든 것처럼 127.0.0.1.alias 파일 및 example.local.alias 파일을 만들 것입니다.
.Alias 파일을 작성하기 전에 LocalHost.yml 파일을 사용할 수 있어야 합니다 .alias localhost.yml 않으면 서버가 분쇄됩니다.
127.0.0.1.alias 파일 내용
localhost
example.local.alias 파일 내용
localhost
우리가 보았 듯이 모든 .alias 파일에는 그들이 가리키는 호스트 이름을 포함해야합니다. 이것은 Shani 응용 프로그램에서 별칭을 만드는 방법입니다.
다시 한 번, 우리의 응용 프로그램은 localhost:8008 통해 사용할 수 있다고 가정 해 봅시다. 웹 서버의 기본 포트는 HTTP의 경우 8008 , HTTP의 경우 포트 44380 입니다. 다음 URL을 사용하여 기능 world 호출 할 수 있습니다.
$ curl http://localhost:8008/greetings/0/hello/0/world축하합니다! Shani 개발자가 되기위한 첫 번째 단계를 완료했습니다.
Shani Application은 다음 URL 패턴을 따릅니다
http://hostname[:port]/module-name/param1/resource-name/param2/function-name[/more-params][?query=q1]
위의 패턴을 분해하면 볼 수 있습니다
module-name 사용자가 요청한 현재 리소스 모듈을 나타냅니다. 이 모듈의 모든 하위 자원이 상주하는 디렉토리입니다.param1 및 param2 는 리소스 식별자이며 숫자, 문자열 또는 무엇이든resource-name 또는 언젠가 controller-name 하위 자원입니다. 응용 프로그램의 실제 구현입니다function-name 리소스 클래스 정의에서 사용 가능한 함수 이름입니다. 함수 이름 후에는 더 많은 매개 변수를 추가하거나 쿼리 문자열을 추가 할 수 있습니다.예:
http://localhost:8008/products/201/sales/10/details
Shani Application은 Kebab에서 Camel Case 변환을 사용하여 URL을 유효한 이름으로 변환합니다.
module-name 프로젝트 구조의 module-name 디렉토리를 나타냅니다.resource-name module-name 디렉토리의 ResourceName 클래스를 나타내고 뷰 디렉토리의 resource-name 디렉토리를 나타냅니다.function-name.php ResourceName function-name functionName다른 URL 부품은 변경되지 않았습니다.
풀 요청을 환영합니다. 주요 변경 사항을 위해 먼저 문제를 열어 변경하고 싶은 것을 논의하십시오.
테스트를 적절하게 업데이트하십시오.
GPL-3.0