Download the PHP package rayzenai/url-manager without Composer

On this page you can find all versions of the php package rayzenai/url-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package url-manager

RayzenAI URL Manager

A comprehensive Laravel package for managing URLs, redirects, and sitemaps with Filament admin panel integration.

Features

Requirements

Installation

Step 1: Install via Composer

Optional: Install File Manager for Enhanced SEO

For complete media SEO functionality, install the companion file-manager package:

This package provides:

Step 2: Publish Configuration

Step 3: Configure Location Service (Required for visitor tracking)

The URL Manager uses the Stevebauman/Location package to detect visitor countries from IP addresses. You need to set up MaxMind's GeoIP database:

Option A: Use Local Database (Recommended)

  1. Download the free GeoLite2 City database from MaxMind
  2. Create a free account and download GeoLite2-City.mmdb
  3. Place the file in your Laravel project: database/maxmind/GeoLite2-City.mmdb
  4. Publish and configure the Location package:

  5. Update config/location.php:

Option B: Use Web Service

Configure MaxMind web service in your .env:

Step 4: Run Migrations

This will create the following tables:

Step 5: Register with Filament

Add the plugin to your Filament panel configuration (typically in app/Providers/Filament/AdminPanelProvider.php):

Step 5: Configure Your Models

Add the HasUrl trait to any model that needs URL management:

Step 6: Register Redirect Middleware

To enable automatic redirect handling when slugs are updated, add the middleware to your bootstrap/app.php:

Why prepend? The middleware must run BEFORE route model binding. If you have a route like /leader/{leader:slug} and someone visits /leader/old-slug, the middleware catches it and redirects to /leader/new-slug before Laravel tries (and fails) to find a model with slug='old-slug'.

What it does:

Usage

Checking Your Configuration

Before you start using URL Manager, check that all your models are properly configured:

This command will verify:

Creating New Models with HasUrl

Generate a new model with HasUrl trait and all required methods pre-configured:

The generated model includes:

Using the UrlManager Facade

For common URL operations, use the UrlManager facade:

Creating URLs for Existing Models

Generate URLs for all models that use the HasUrl trait:

Or for a specific model:

Handling Large Datasets

For large datasets with thousands of records, you may need to increase PHP memory and execution limits:

Creating Redirects

Via Filament Admin

  1. Navigate to the URLs section in your Filament admin panel
  2. Click "Create Redirect"
  3. Enter the source and destination URLs
  4. Choose redirect type (301 or 302)

Programmatically

Generating Sitemaps

Generate a sitemap with all active URLs:

For large sites (>10,000 URLs), the package automatically creates multiple sitemap files with an index.

Including Custom Static Routes

You can include static routes in your sitemap that aren't tied to database models. This is useful for:

Configure custom routes in config/url-manager.php:

Available Options:

These routes will be automatically included when you run:

Submitting Sitemaps to Search Engines

Since Google deprecated the ping endpoint in June 2023 and Bing has also discontinued their ping service, API credentials are now required for automated sitemap submission.

Setting up Google Search Console API

Prerequisites:

Using Service Account Authentication
  1. Create a Google Cloud Project:

    • Go to Google Cloud Console
    • Create a new project or select an existing one
    • Enable these APIs:
      • "Google Search Console API"
      • "Search Console API" (if available)
    • Note: The "Indexing API" is separate and not needed for sitemap submission
  2. Create a Service Account:

    • Navigate to "IAM & Admin" > "Service Accounts"
    • Click "Create Service Account"
    • Give it a name like "sitemap-submitter"
    • Click "Create and Continue"
    • Skip the optional role assignment (click "Continue")
    • Click "Done"
    • Find your new service account in the list and click on it
    • Go to the "Keys" tab
    • Click "Add Key" > "Create New Key"
    • Select "JSON" format
    • Click "Create" to download the JSON credentials file
    • Keep this file secure - it contains credentials for API access
  3. Add Service Account to Search Console:

    • Go to Google Search Console
    • Select your property
    • Go to Settings > Users and permissions
    • Click "Add user"
    • Enter the service account email (found in the JSON file, looks like [email protected])
    • Select "Owner" permission level
    • Click "Add"
  4. Configure in Admin Panel:

    • Navigate to the Google Search Console settings page in your Filament admin panel
    • Toggle "Enable Google Search Console Integration" to ON
    • Enter your site URL or domain property:
      • For URL-prefix property: https://www.yoursite.com (must match exactly)
      • For Domain property: sc-domain:yoursite.com (recommended - covers all subdomains and protocols)
    • Add your Service Account credentials:
      • Open your downloaded JSON file in a text editor
      • Copy the entire JSON content
      • Paste it into the "Service Account JSON" field
      • The service account email will be automatically extracted
    • Click "Save Settings"
    • Use "Test Connection" to verify the setup is working

    Why Database Storage?

    • Credentials are encrypted and stored securely in your database
    • Survives deployments (no need to re-upload files)
    • No file system dependencies
    • Easier to manage in production environments

Submitting Sitemaps

Once configured, you can submit sitemaps in multiple ways:

  1. Via Admin Panel:

    • Go to URLs management page in Filament
    • Click "Submit to Search Engines" button
  2. Via Command Line:

  3. Programmatically:

Troubleshooting Google Search Console

Service Account Issues:

General Issues:

Note on Bing

Bing has also discontinued their ping endpoint. Sitemaps must be manually submitted through Bing Webmaster Tools.

Accessing URLs in Your Application

Visit Tracking

The package automatically tracks URL visits, but to track view counts on your models, you need to implement the getViewCountColumn() method:

Important: Make sure your database migration includes the view count column:

The package provides two ways to track visits:

Method 1: Using Middleware (Recommended for Livewire & API Routes)

Register the middleware in your application:

For Laravel 11 - Add to bootstrap/app.php:

For Laravel 10 and below - Add to app/Http/Kernel.php:

Then apply the middleware to your routes:

The middleware automatically:

Method 2: Using Fallback Route

If you use the package's fallback route controller:

Visits are automatically tracked for any URL managed by the package.

Accessing Visit Data

Note: The difference between URL visits and model view counts:

Visitor Analytics Features

The URL Manager provides comprehensive visitor tracking with the following features:

Country Detection

Mobile App Detection

The package intelligently detects mobile app traffic through:

Populate Existing Data

If you have existing visitor data without country codes, run:

This command will:

Visitor Information Tracked

Testing Referrer Tracking

The package includes a built-in test page to verify that referrer tracking is working correctly. This is especially useful when setting up the package or debugging referrer capture issues.

Access the test page (only available in non-production environments):

The test page provides:

How it works:

  1. Visit the test page at /_url-manager/test
  2. Add your entity slugs (e.g., entities/my-product, blog/my-post)
  3. Click on the links to visit those pages
  4. Check Filament admin panel โ†’ URL Visits โ†’ Toggle "Referrer" column
  5. You should see the test page URL as the referrer

The test page uses a multi-layer approach to ensure referrers are captured:

Note: The test route is automatically disabled in production environments for security.

Configuration

The configuration file config/url-manager.php allows you to customize:

Advanced Features

UrlManager Facade

The UrlManager facade provides a convenient API for common URL operations:

When to use the facade:

When NOT to use it:

Custom URL Types

Register custom URL types in your configuration:

SEO Metadata

Models can provide SEO metadata through the getSeoMetadata() method:

Event Handling

Listen for URL events in your application:

Media SEO with File Manager

If you have the kirantimsina/file-manager package installed, you can enhance your SEO by managing media metadata:

Populate SEO Titles for Images

Generate SEO-friendly titles for all your media files:

The command automatically generates SEO-friendly titles based on:

Image Sitemap Generation

Generate a dedicated image sitemap for better image SEO:

Features:

Performance Optimization:

Image Size Configuration

Configure the image size used in sitemaps in config/url-manager.php:

The available sizes are defined in your config/file-manager.php:

SEO Title Configuration

Control which models receive SEO titles in config/file-manager.php:

Media Metadata in Sitemaps

When using file-manager, media files are automatically included in your sitemaps with proper SEO titles and metadata for better search engine indexing. The integration:

Multiple Sitemap Support

For sites with more than 10,000 URLs, the package automatically generates multiple sitemap files:

Filament Admin Panel

The package includes a complete Filament resource with:

Dashboard Widgets

The package provides two dashboard widgets:

  1. URL Stats Overview - Displays total URLs, redirects, and visit statistics
  2. Top URLs Table - Shows the 10 most visited URLs with their metrics

Filament Form Components

UrlInput Component

The package provides a UrlInput form component for managing slugs in Filament forms:

Allowing Slug Updates:

By default, slugs are disabled when editing records to prevent breaking existing URLs. To allow updates (with automatic redirect creation):

How it works:

Example:

  1. Leader has slug kp-oli with URL /leader/kp-oli
  2. Admin updates slug to kp-sharma-oli in Filament
  3. Database now has:
    • Active URL: /leader/kp-sharma-oli (points to leader)
    • Redirect: /leader/kp-oli โ†’ /leader/kp-sharma-oli
  4. Users visiting old URL are automatically redirected

Best Practices

  1. Always include an active field (is_active or active) in models using HasUrl trait
  2. Include a slug field in models using HasUrl trait (override via slugField() if using different name)
  3. Implement webUrlPath() method to define URL structure
  4. Override activeUrlField() method if using a field name other than is_active
  5. Use meaningful slugs for SEO optimization
  6. Allow slug updates safely - Use UrlInput::make('slug')->allowUpdatingSlug() for automatic redirect creation
  7. Generate sitemaps regularly (via cron job)
  8. Circular redirects are prevented automatically - The package detects and blocks Aโ†’Bโ†’A or Aโ†’Bโ†’Cโ†’A chains
  9. Use appropriate HTTP status codes (301 for permanent, 302 for temporary)

Testing

Run the package tests:

Troubleshooting

URLs not generating for models

Ensure your model:

Common URL Generation Issues

  1. "URL with slug already exists for different model" Warning

    • This occurs when multiple models have the same slug
    • Solution: Ensure unique slugs within each model type
    • The command skips duplicates to maintain data integrity
  2. Not all URLs are generated

    • Check for duplicate slugs in your data
    • Verify models have unique slug values
    • For large datasets, increase PHP memory limit
    • Run the command multiple times if needed
  3. Models using 'active' instead of 'is_active'
    • Override the activeUrlField() method in your model:

Sitemap not accessible

Check that:

Redirects not working

Verify:

Contributing

Contributions are welcome! Please submit pull requests with tests.

License

MIT License. See LICENSE file for details.

Support

For issues and questions, please use the GitHub issue tracker.

Credits

Created by Kiran Timsina at RayzenAI.


All versions of url-manager with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^11.0||^12.0||^13.0
filament/filament Version ^5.0
spatie/laravel-package-tools Version ^1.16
spatie/laravel-sitemap Version ^7.0
google/apiclient Version ^2.0
jenssegers/agent Version ^2.6
laravel/sanctum Version ^4.0
stevebauman/location Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rayzenai/url-manager contains the following files

Loading the files please wait ...