承接 neuralglitch/google-fonts 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

neuralglitch/google-fonts

Composer 安装命令:

composer require neuralglitch/google-fonts

包简介

Google Fonts integration for Symfony with development CDN and production font locking

README 文档

README

Google Fonts

Google Fonts integration for Symfony

PHP Version Symfony
PHPUnit Coverage PHPStan
Psalm Infection Code Style
Release Downloads License

Features

  • Twig Function - Simple {{ google_fonts() }} function
  • Development Mode - Google Fonts CDN with inline styles
  • Production Mode - Lock fonts locally for better performance and privacy
  • Smart CSS - Automatic font styling for body, headings, and bold text
  • CLI Tools - Search, import, lock, and warm-cache commands
  • High Performance - Optimized with full template caching support

Prerequisites

For fully automatic setup, visit the related Flex recipe repository and follow the instructions to add it to the composer.json in the consuming project, as the recipe is not yet part of the Symfony’s main recipe repository.

Installation

composer require neuralglitch/google-fonts

Quick Start

1. Add fonts to your template

{# templates/base.html.twig #}
<head>
  {# Normal font for body and headings #}
  {{ google_fonts('Ubuntu', '300 400 500 700', 'normal italic') }}
  
  {# Monospace font for code elements #}
  {{ google_fonts('JetBrains Mono', '400 500', 'normal', null, true) }}
</head>

2. Lock fonts for production

php bin/console gfonts:lock

This downloads fonts to assets/fonts/ (served by AssetMapper in dev, compiled to public/ in prod).

Each font gets a single CSS file containing both @font-face declarations and intelligent styling rules.

The bundle automatically switches to locked fonts in production (via when@prod configuration).

Troubleshooting: If locked fonts aren't being used in production, see the Production Setup guide.

3. Optional: Configure API key for search/import commands

# .env.local
GOOGLE_FONTS_API_KEY=your_api_key_here

Get your free API key at Google Cloud Console.

Note: The API key is only required for gfonts:search and gfonts:import commands. The google_fonts() Twig function and gfonts:lock command do NOT require an API key.

Documentation

Requirements

  • PHP 8.1 or higher
  • Symfony 6.4, 7.x, or 8.x
  • Twig 3.0 or higher

Support

License

MIT

统计信息

  • 总下载量: 631
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固