Skip to content

Instantly share code, notes, and snippets.

@tnylea
Created April 16, 2017 16:56
Show Gist options
  • Select an option

  • Save tnylea/293aacdf078fa4e87ccc11d09d12d1cb to your computer and use it in GitHub Desktop.

Select an option

Save tnylea/293aacdf078fa4e87ccc11d09d12d1cb to your computer and use it in GitHub Desktop.
Change the Laravel File Structure so that way users can easily upload it to any server
#!/bin/sh
# Make our New Application folder
mkdir application
# Loop through all the files in the current directory and move them to the new application folder
# Exclude '.', '..', 'application', and 'uploadable.sh'
for i in `ls -a`;
do
if [ $i != 'application' ] && [ $i != 'uploadable.sh' ] && [ $i != '.' ] && [ $i != '..' ] && [ $i != '.DS_Store' ]
then
mv $i application/$i;
fi
done;
# Move all contents from public folder out to root folder
mv application/public/* ./
mv application/public/.* ./
rm -rf application/public
# Next, let's move and rename the ./application/storage/app/public to ./storage
mv application/storage/app/public ./storage
# We now need to set our index.php file to include our /application folder
# Example instead of require __DIR__.'/../bootstrap/autoload.php';
# it should load require __DIR__.'/application/bootstrap/autoload.php';
sed "s/require __DIR__.'\/..\/bootstrap\/autoload.php';/require __DIR__.'\/application\/bootstrap\/autoload.php';/" index.php > index-bkup.php
sed "s/require_once __DIR__.'\/..\/bootstrap\/app.php';/require_once __DIR__.'\/application\/bootstrap\/app.php';/" index-bkup.php > index.php
rm index-bkup.php
# We now need to change the default storage location for local and public
sed "s/'root' => storage_path('app') . '\/public',/'root' => '.\/storage',/" application/config/filesystems.php > application/config/filesystems-bkup.php
sed "s/'root' => storage_path('app\/public'),/'root' => '.\/storage',/" application/config/filesystems-bkup.php > application/config/filesystems.php
rm application/config/filesystems-bkup.php
# Make sure that we prevent access to the .env file
echo '
<FilesMatch "\.env">
Order deny,allow
Deny from all
</FilesMatch>' >> .htaccess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment