Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Code Snippets

Code Snippets Laravel Package

permafrost-dev/code-snippets

Laravel package for managing reusable code snippets: create, organize, tag, and quickly retrieve snippets for your projects. Includes an admin UI, storage/database support, and tools to share or reuse snippets across teams and environments.

View on GitHub
Deep Wiki
Context7

Easily create and work with code snippets from PHP

Frequently asked questions about Code Snippets
How do I install and set up this package in a Laravel 10 project?
Run `composer require permafrost-dev/code-snippets` to install. Publish migrations with `php artisan vendor:publish --tag=snippets-migrations` and run them. The package uses Eloquent, so no additional Laravel-specific setup is needed beyond database configuration.
Does this package support syntax highlighting for languages other than PHP?
Yes, it uses PHP’s built-in `highlight_string()` function, which supports most common languages (PHP, JavaScript, Python, etc.). For advanced syntax highlighting, you may need to integrate a third-party library like `vlucas/phpdotenv` or `squizlabs/php_codesniffer` for customization.
Can I use this package for a public documentation site with user-submitted snippets?
The package provides basic CRUD and tagging but lacks built-in validation for XSS or malicious content. For public-facing sites, you’ll need to add sanitization (e.g., `htmlspecialchars()`) and consider rate-limiting or authentication middleware to restrict snippet submissions.
Will this package work with Laravel 10 and PHP 8.2+?
The package was last updated in 2021 and targets PHP 7.4+ and Laravel 8+. While it may work with Laravel 10 and PHP 8.2, test thoroughly for compatibility, especially with Eloquent or dependency changes. No guarantees are provided for newer Laravel versions.
How can I add search functionality beyond basic LIKE queries?
For advanced search, consider integrating Laravel Scout with a full-text search engine like Algolia or Meilisearch. Alternatively, use database-specific features like PostgreSQL’s `tsvector` or MySQL’s `FULLTEXT` indexes for better performance on large snippet collections.
Is there a way to version or diff code snippets over time?
The package does not include built-in versioning. To implement this, you’d need to extend the `Snippet` model with a `versions` table or use Laravel’s `laravel-model-versions` package to track changes automatically.
Can I expose snippets via an API for a React/Vue frontend?
The package doesn’t include API endpoints, but you can create custom routes/controllers to return snippets as JSON. Use Laravel Sanctum or Passport for authentication if needed. Example: `Route::get('/api/snippets', [SnippetController::class, 'index']);`
How do I organize snippets by programming language or team?
Use the built-in `tags` and `categories` relationships (via Eloquent) to group snippets. For example, create a `Language` model and pivot table to associate snippets with languages like PHP, JavaScript, or Python. Teams can be handled similarly with a `Team` model.
What are the performance considerations for large-scale snippet storage?
For read-heavy workloads, cache frequently accessed snippets using Redis or Memcached with tags (e.g., `snippet:123`). For write-heavy workloads, ensure database indexes are optimized on `tags` and `categories`. If storing millions of snippets, consider archiving older ones or using a dedicated search engine.
Are there alternatives if this package doesn’t meet my needs?
For simpler needs, consider using Laravel’s Filesystem to store snippets as files with metadata in the database. For advanced features like collaboration or versioning, explore Spatie’s `laravel-activitylog` or self-built solutions with Laravel Nova or Filament for admin interfaces.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource