Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

earmsby's avatar

non Laravel PHP site on Forge

I'm trying to deploy a vanilla PHP site to Forge. I've deployed Laravel sites successfully using GitHub but am having trouble with this non-Laravel site.

Am I correct that (unlike Laravel) the entire site should be located in the "public" folder? If so, is there a way to have the git repo go into that folder when running a deployment? Or do I have to wrap the whole site in the public folder in my repo?

Sorry for asking a non-Laravel question on a site devoted to Laravel. I hope it's allowed since the topic is Forge, which I am using. :)

0 likes
2 replies
LaryAI's avatar
Level 58

When deploying a non-Laravel PHP site on Forge, you can indeed use the "public" folder as the web root, similar to how Laravel sites are structured. However, you have a couple of options for organizing your repository and deployment process:

  1. Structure Your Repository with a Public Folder:

    • You can structure your repository so that the main entry point files (like index.php) and any publicly accessible assets (like CSS, JavaScript, and images) are inside a public directory. This way, when you deploy, the contents of the public directory will naturally map to the web root on Forge.

    Example repository structure:

    my-php-site/
    ├── public/
    │   ├── index.php
    │   ├── css/
    │   ├── js/
    │   └── images/
    ├── src/
    └── vendor/
    
  2. Deploy to a Subdirectory and Symlink:

    • If you prefer not to restructure your repository, you can deploy the entire repository to a subdirectory on your Forge server and then create a symbolic link from the public directory in your repository to the web root.

    Steps:

    • Deploy your repository to a directory like /home/forge/yourdomain.com/source.
    • Create a symbolic link from the public directory in your repository to the web root:
      ln -s /home/forge/yourdomain.com/source/public /home/forge/yourdomain.com/public
      
  3. Modify the Deployment Script:

    • You can also modify the deployment script in Forge to move the contents of your repository's public directory to the web root after each deployment.

    Example deployment script modification:

    #!/bin/bash
    
    # Navigate to the deployment directory
    cd /home/forge/yourdomain.com
    
    # Pull the latest changes
    git pull origin main
    
    # Move the contents of the public directory to the web root
    rsync -av --delete source/public/ .
    
    # Run any other necessary deployment commands
    

By using one of these methods, you can effectively deploy a non-Laravel PHP site on Forge while keeping your repository organized and your deployment process smooth.

martinbean's avatar

@earmsby The simplest solution would be, in your Forge deployment script, just to cd into the public directory instead of the root directory:

- cd /home/forge/yoursite
+ cd /home/forge/yoursite/public
  git pull origin $FORGE_SITE_BRANCH

  # The rest of your deployment script...

Please or to participate in this conversation.