Path in the Gestor bibliotecas/recursos.php
Resolves the URL of a static asset (JS, CSS, image, font) of the Gestor or of a module. Always loaded by config.php.
The Gestor code lives outside the public folder. An asset can reach the browser in two ways:
-
Published to
public_html/dist/:c2f assets:publish(called byresources:syncand by the deploy) copies the assets there and writes thedist/.manifest.jsoninventory. Nginx or Apache serve the file straight from disk, without PHP. -
Through the
arquivo-estaticocontroller: without publication, the historical URL (<url-raiz>interface/interface.js) goes through PHP, which reads the file fromgestor/assets/or from the module.
recursos_url() picks dist/ only when the file is in the manifest. In development, on a fresh installation or with an asset not published yet, the URL stays the old one, and nothing breaks.
Usage
echo recursos_tag_js('interface/interface.js', $version, 'defer');
echo recursos_tag_css('admin-arquivos/css.css');
$url = recursos_url_versionada('images/logo.png');| Function | Does |
|---|---|
recursos_url($caminho, $base = null) |
URL in dist/ if published; otherwise <url-raiz or $base><path> |
recursos_versao($caminho, $padrao = null) |
The content hash, from the manifest; otherwise $padrao; otherwise gestor_asset_version() |
recursos_url_versionada() |
recursos_url() + ?v=<version> |
recursos_tag_js() / recursos_tag_css() |
The ready <script> / <link rel="stylesheet"> tag |
recursos_publicado($caminho) / recursos_dist_ativo() |
Lookups in the manifest loaded into $_GESTOR['dist-manifest'] |
recursos_caminho_normalizar($caminho) |
Strips ?/#, extra and leading slashes; rejects .. and null bytes ('') |
recursos_dist_mapear_fonte($relativo) |
The source → dist/ contract, shared with assets:publish |
The path contract
The path inside dist/ is the same as the public URL:
| Source in the Gestor | In dist/ and in the URL |
|---|---|
assets/<path> |
<path> |
modulos/<m>/<m>.js / <m>.css |
<m>/js.js / <m>/css.css |
modulos/<m>/<m>.<option>.js |
<m>/<option>.js |
.min.js has no path of its own: it is the preferred variant of the authored file, chosen at publication and, at runtime, by arquivo-estatico.
The dist/ folder uses url-raiz-sem-lang: the same file does not get one URL per language. dist-ativo turns on by itself in production and can be forced with ASSETS_DIST in the .env; PUBLIC_PATH tells where the public folder is when the Gestor runs from the CLI (global variables).
Functions
Generated from gestor/bibliotecas/recursos.php · 9 functions
recursos_caminho_normalizar
view source · line 43 ↗recursos_caminho_normalizar(string $caminho): stringNormaliza um caminho de asset para a forma usada como chave do manifesto.
Parameters
$caminhostring- Caminho relativo do asset, como aparece na URL.
Returns
recursos_dist_ativo
view source · line 61 ↗recursos_dist_ativo()Indica se a instalação tem assets publicados e habilitados para entrega direta.
recursos_publicado
view source · line 73 ↗recursos_publicado(string $caminho): boolInforma se um asset consta no manifesto publicado em dist/.
Parameters
$caminhostring- Caminho relativo do asset (com ou sem query string).
Returns
recursos_url
view source · line 102 ↗recursos_url(string $caminho, string|null $base = null): stringURL pública de um asset.
Parameters
$caminhostring- Caminho relativo do asset, opcionalmente com query string.
$basestring|null- Raiz pública usada no fallback; null usa
url-raiz.
Returns
src/href.recursos_versao
view source · line 128 ↗recursos_versao(string $caminho, string|null $versaoPadrao = null): stringToken de cache busting de um asset publicado.
Parameters
$caminhostring- Caminho relativo do asset.
$versaoPadraostring|null- Versão usada quando o asset não está publicado.
Returns
recursos_url_versionada
view source · line 149 ↗recursos_url_versionada(string $caminho, string|null $versao = null, string|null $base = null): stringURL de um asset já com o parâmetro de cache busting.
Parameters
$caminhostring- Caminho relativo do asset.
$versaostring|null- Versão a usar quando o asset não está publicado.
$basestring|null- Raiz pública do fallback; null usa
url-raiz.
Returns
recursos_tag_js
view source · line 162 ↗recursos_tag_js(string $caminho, string|null $versao = null, string $extra = '', string|null $base = null): stringTag <script> de um asset do gestor.
Parameters
$caminhostring- Caminho relativo do asset.
$versaostring|null- Versão usada quando o asset não está publicado.
$extrastring- Atributos adicionais já formatados (ex.:
defer). $basestring|null- Raiz pública do fallback; null usa
url-raiz.
Returns
recursos_tag_css
view source · line 177 ↗recursos_tag_css(string $caminho, string|null $versao = null, string $extra = '', string|null $base = null): stringTag <link rel="stylesheet"> de um asset do gestor.
Parameters
$caminhostring- Caminho relativo do asset.
$versaostring|null- Versão usada quando o asset não está publicado.
$extrastring- Atributos adicionais já formatados (ex.:
data-c2f-css-role="quill"). $basestring|null- Raiz pública do fallback; null usa
url-raiz.
Returns
recursos_dist_mapear_fonte
view source · line 204 ↗recursos_dist_mapear_fonte(string $relativo): stringContrato de mapeamento entre o arquivo FONTE no gestor e o caminho publicado em dist/.
Parameters
$relativostring- Caminho do arquivo relativo à raiz do gestor, com
/como separador.
Returns
dist/, ou '' quando o arquivo não é publicável.