
번역 : Español
HTML 링크 및 스크립트 처리를위한 PHP 라이브러리.
운영 체제 : Linux | 창.
PHP 버전 : 8.1 | 8.2.
이 확장을 설치하는 선호하는 방법은 작곡가를 통하는 것입니다.
PHP 자산 라이브러리를 설치하려면 간단히
composer require josantonius/asset이전 명령은 필요한 파일 만 설치합니다. 사용할 수있는 전체 소스 코드를 다운로드 하려는 경우 다음과 같습니다.
composer require josantonius/asset --prefer-source전체 저장소를 GIT로 복제 할 수도 있습니다.
git clone https://github.com/josantonius/php-asset.git JosantoniusAssetAsset
신체에 추가 된 스크립트를 인쇄하십시오.
public function outputBodyScripts(): string ;헤드에 추가 된 스크립트를 인쇄하십시오.
public function outputHeadScripts(): string ;추가 된 링크 인쇄 :
public function outputLinks(): string ; JosantoniusAssetFacadesAsset
바디 스크립트 추가 :
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
public static function addBodyScript(
null | bool $ async = null ,
null | string $ crossorigin = null ,
null | bool $ defer = null ,
null | string $ fetchpriority = null ,
null | string $ integrity = null ,
null | bool $ nomodule = null ,
null | string $ nonce = null ,
null | string $ referrerpolicy = null ,
null | string $ src = null ,
null | string $ type = null
): BodyScript ;헤드 스크립트 추가 :
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
public static function addHeadScript(
null | bool $ async = null ,
null | string $ crossorigin = null ,
null | bool $ defer = null ,
null | string $ fetchpriority = null ,
null | string $ integrity = null ,
null | bool $ nomodule = null ,
null | string $ nonce = null ,
null | string $ referrerpolicy = null ,
null | string $ src = null ,
null | string $ type = null
): HeadScript ;링크 추가 :
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
*/
public static function addLink(
null | string $ as = null ,
null | string $ crossorigin = null ,
null | bool $ disabled = null ,
null | string $ fetchpriority = null ,
null | string $ href = null ,
null | string $ hreflang = null ,
null | string $ imagesizes = null ,
null | string $ imagesrcset = null ,
null | string $ integrity = null ,
null | string $ media = null ,
null | string $ prefetch = null ,
null | string $ referrerpolicy = null ,
null | string $ rel = null ,
null | string $ sizes = null ,
null | string $ target = null ,
null | string $ title = null ,
null | string $ type = null ,
): Link ;신체에 추가 된 스크립트를 인쇄하십시오.
public static function outputBodyScripts(): string ;헤드에 추가 된 스크립트를 인쇄하십시오.
public static function outputHeadScripts(): string ;추가 된 링크 인쇄 :
public static function outputLinks(): string ; JosantoniusAssetElementsBodyScript
바디 스크립트 추가 :
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
public function __construct(
private null | bool $ async = null ,
private null | string $ crossorigin = null ,
private null | bool $ defer = null ,
private null | string $ fetchpriority = null ,
private null | string $ integrity = null ,
private null | bool $ nomodule = null ,
private null | string $ nonce = null ,
private null | string $ referrerpolicy = null ,
private null | string $ src = null ,
private null | string $ type = null
); JosantoniusAssetElementsHeadScript
헤드 스크립트 추가 :
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
*/
public function __construct(
private null | bool $ async = null ,
private null | string $ crossorigin = null ,
private null | bool $ defer = null ,
private null | string $ fetchpriority = null ,
private null | string $ integrity = null ,
private null | bool $ nomodule = null ,
private null | string $ nonce = null ,
private null | string $ referrerpolicy = null ,
private null | string $ src = null ,
private null | string $ type = null
); JosantoniusAssetElementsLink
링크 추가 :
/**
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link
*/
public function __construct(
private null | string $ as = null ,
private null | string $ crossorigin = null ,
private null | bool $ disabled = null ,
private null | string $ fetchpriority = null ,
private null | string $ href = null ,
private null | string $ hreflang = null ,
private null | string $ imagesizes = null ,
private null | string $ imagesrcset = null ,
private null | string $ integrity = null ,
private null | string $ media = null ,
private null | string $ prefetch = null ,
private null | string $ referrerpolicy = null ,
private null | string $ rel = null ,
private null | string $ sizes = null ,
private null | string $ target = null ,
private null | string $ title = null ,
private null | string $ type = null ,
);이 라이브러리의 사용 예 :
use Josantonius Asset Elements BodyScript ;
new BodyScript (
src: ' https://example.com/script.js '
); use Josantonius Asset Facades Asset ;
Asset:: addBodyScript (
src: ' script.js ' ,
type: ' text/javascript '
); use Josantonius Asset Elements HeadScript ;
new HeadScript (
src: ' script.js ' ,
type: ' module '
); use Josantonius Asset Facades Asset ;
Asset:: addHeadScript (
crossorigin: ' anonymous ' ,
defer: true ,
integrity: ' sha256-n9+ ' ,
src: ' https://example.com/script.js ' ,
type: ' text/javascript '
); use Josantonius Asset Elements Link ;
new Link (
crossorigin: ' anonymous ' ,
href: ' https://example.com/style.css ' ,
integrity: ' sha256-n9+ ' ,
media: ' all ' ,
rel: ' stylesheet '
); use Josantonius Asset Facades Asset ;
Asset:: addLink (
href: ' https://example.com/style.css ' ,
rel: ' stylesheet '
); use Josantonius Asset Asset ;
$ asset = new Asset ();
echo $ asset -> outputBodyScripts (); use Josantonius Asset Facades Asset ;
echo Asset:: outputBodyScripts (); use Josantonius Asset Asset ;
$ asset = new Asset ();
echo $ asset -> outputHeadScripts (); use Josantonius Asset Facades Asset ;
echo Asset:: outputHeadScripts (); use Josantonius Asset Asset ;
$ asset = new Asset ();
echo $ asset -> outputLinks (); use Josantonius Asset Facades Asset ;
echo Asset:: outputLinks (); index.php
use Josantonius Asset Elements Link ;
use Josantonius Asset Elements BodyScript ;
use Josantonius Asset Elements HeadScript ;
new BodyScript (src: ' foo.js ' , async: true );
new BodyScript (src: ' bar.js ' , type: ' text/javascript ' );
new HeadScript (src: ' https://example.com/foo.js ' , type: ' module ' );
new HeadScript (src: ' https://example.com/bar.js ' , defer: true );
new Link (href: ' https://example.com/foo.css ' , rel: ' stylesheet ' );
new Link (href: ' https://example.com/bar.css ' , rel: ' stylesheet ' , media: ' all ' ); page.html
< ?php
use JosantoniusAssetAsset;
$asset = new Asset();
? >
< html >
< head >
< ?= $asset- > outputLinks() ? >
< ?= $asset- > outputHeadScripts() ? >
</ head >
< body >
< ?= $asset- > outputBodyScripts() ? >
</ body >
</ html >결과:
< html >
< head >
< link href =" https://example.com/foo.css " rel =" stylesheet " >
< link href =" https://example.com/bar.css " rel =" stylesheet " media =" all " >
< script src =" https://example.com/foo.js " type =" module " > </ script >
< script defer src =" https://example.com/bar.js " > </ script >
</ head >
< body >
< script async src =" foo.js " > </ script >
< script src =" bar.js " type =" text/javascript " > </ script >
</ body >
</ html > index.php
use Josantonius Asset Facades Asset ;
Asset:: addBodyScript (src: ' foo.js ' , async: true );
Asset:: addBodyScript (src: ' bar.js ' , type: ' text/javascript ' );
Asset:: addHeadScript (src: ' https://example.com/foo.js ' , type: ' module ' );
Asset:: addHeadScript (src: ' https://example.com/bar.js ' , defer: true );
Asset:: addLink (href: ' https://example.com/foo.css ' , rel: ' stylesheet ' );
Asset:: addLink (href: ' https://example.com/bar.css ' , rel: ' stylesheet ' , media: ' all ' ); page.html
< ?php
use JosantoniusAssetFacadesAsset;
? >
< html >
< head >
< ?= Asset::outputLinks() ? >
< ?= Asset::outputHeadScripts() ? >
</ head >
< body >
< ?= Asset::outputBodyScripts() ? >
</ body >
</ html >결과:
< html >
< head >
< link href =" https://example.com/foo.css " rel =" stylesheet " >
< link href =" https://example.com/bar.css " rel =" stylesheet " media =" all " >
< script src =" https://example.com/foo.js " type =" module " > </ script >
< script defer src =" https://example.com/bar.js " > </ script >
</ head >
< body >
< script async src =" foo.js " > </ script >
< script src =" bar.js " type =" text/javascript " > </ script >
</ body >
</ html > 테스트를 실행하려면 작곡가가 필요하고 다음을 실행하려면 다음을 수행합니다.
git clone https://github.com/josantonius/php-asset.git cd php-asset composer installPhPunit으로 단위 테스트 실행 :
composer phpunitPHPC로 코드 표준 테스트를 실행하십시오.
composer phpcsCode 스타일의 불일치를 감지하기 위해 PHP Mess Detector 테스트를 실행하십시오.
composer phpmd모든 이전 테스트 실행 :
composer tests <script> 태그 사이에 코드를 추가하려면 기능을 추가하십시오 각 릴리스에 대한 자세한 변경 사항은 릴리스 노트에 문서화되어 있습니다.
기고 가이드를 읽으십시오. 풀 요청을하기 전에 토론을 시작하거나 문제를보고하십시오.
모든 기고자들에게 감사합니다! ❤️
이 프로젝트가 개발 시간을 줄이는 데 도움이된다면 오픈 소스 작업을 지원하기 위해 저를 후원 할 수 있습니까?
이 저장소는 MIT 라이센스에 따라 라이센스가 부여됩니다.
Copyright © 2016-Present, Josantonius