Laravel Envoyer - Where to store user uploads - php

Docs basically says I need a envoyer-root/storage folder alongside with envoyer-root/current and envoyer-root/releases and then use a system link to link envoyer-root/storage to envoyer-root/releases/{latest one}/public/storage in order to read those files.
What nobody seems to explain is, where are the newly uploaded files saved to? By my application, they'd be uploaded to envoyer-root/releases/{latest one}/public/storage but that wont make it accessible for the new releases.
Do I have to create a post-deploy and manually copy all the files from the previous release to the envoyer-root/storage folder and THEN linking it? Am I missing something?
PD: for references, I'm using Envoyer with a non-laravel project, so I need to understand if I have to modify my source code to work with Envoyer (which seems smelly to me but w/e we already paid for it), or if I don't and I'm not seeing something.

Use the "Linked Folders" (within the Deployment hooks tab) to create a symlink from the currently deployed release to a shared storage folder on the server.
So in your case, you'd want to create a symlink from the currently deployed release to the envoyer-root/storage. In Envoyer, the link from/link at is relative to the "PHP project root", which is your currently deployed release, and the to link is relative to the server root, so you'd have:
Create link at: public/storage (relative to release path)
To: storage (relative to server root)
Symlinks created through the linked folders feature are created on each deployment, so it will always create a symlink for each new release.

Related

How do I view the files on my server?

I am developing a web application using Laravel. I am using Laravel Forge with a Linode server and GitHub. My site is live at the moment. Whenever I change the code, I commit the changes using GitHub for Windows and then deploy the website on Laravel Forge.
One part of my application allows a user to upload a file. This works grand. I can upload a file and then download it from another computer on the website. However, I am not sure how to view the files on my server. They are not appearing on GitHub, and I cannot see anywhere on Laravel Forge to locate these files.
Anyone have any ideas?
The files are definitely there as I said, I can download and view the files once they are uploaded. I am storing them in a files folder in my public directory.
I guess your problem is that the versioner(Git) is ignoring your files.
Verify that where your files are stored and that the .gitignore files in each folder do not ignore them
*
/ Storage_path
Storage_file.extension
*.extension
Modify your corresponding .gitignore files and then commit everything

Git workflow, am I doing it right?

More and more projects are starting to pile up and I want some workflow and also version control over the different projects. I'm trying to set the "right" workflow with Xampp, Git, GitDesktop and PhpStorm on a Windows 2012r2 machine.
Xampp base: d:\xampp
http://localhost = d:\xampp\htdocs
Dev repositories: d:\xampp\htdocs\repositories\dev\GitDemo
Live repositories: d:\xampp\htdocs\repositories\live\GitDemo
Live folder: d:\xampp\htdocs\GitDemo
Live URL: http://servername/GitDemo (intranet use only)
Right now I have my repositories folder inside the htdocs folder, otherwise I would need another alias/copy action to be able to see what I'm developing. But at the same time the repositories folder is exposed. How to hide this? htaccess?
I've ran git init --bare inside the live folder for this project. With GitDesktop I've created the repository for GitDemo inside d:\xampp\htdocs\repositories\dev.
Using PhpStorm I've created a project based upon local files and pointed it towards d:\xampp\htdocs\repositories\dev\GitDemo. I'm able to see the changes made using git status, add them using git add . and commit them succesfully with git commit -m "my commit..".
I've created a remote server git remote add live master and created a post-receive to checkout the files inside d:\xampp\htdocs\repositories\live\GitDemo to d:\xampp\htdocs\GitDemo.
This all feels like a "ton" of work to set up initially and somewhat redundant (having the same files in 3 locations).
Is this the ideal way to set this up, or do you suggest an alternative approach? Thanks for sharing your thoughts!
I've been thinking about the most logical solution (to my opinion at this moment). Here's how I solved my unclear items as described:
I've optimized it by:
Bringing the repositories directory outside htdocs to d:\repositories\dev\ and d:\repositories\live.
I've set up a symlink to http://localhost/dev/GitDemo that links to
d:\repositories\dev\GitDemo. In this way I don't need to place the
repositories folder inside the htdocs folder and still benefit from
Apache being able to serve the content, which actually resides outside the htdocs folder.
The live version is now placed at http://localhost/GitDemo and with a post-receive hook it gets deployed from d:\repositories\live\GitDemo.git to d:\xampp\htdocs\GitDemo.
If you think I made a mistake or have mistaken something from the way it's supposed to be, please correct me as I'm still not sure this is the correct way but at least it seems like it to me.

Running Eclipse php project from a shared folder

I have been using Eclipse Kepler along with PDT tools on local system to manage PHP projects and its turned out to be a better choice for me then the other editors around. Only problem I've found in this environment is that content assist is only available when you open a file residing in the workspace.
Now my problem, I am assigned to work on a PHP Project which is on another system on the local LAN network. Is there any way I can add that project folder to eclipse? so that I can directly edit and save the files on the remote system?
Things I can't look into for various reasons
Using a version control system
Copy source files to local system work
on them and then upload it (kinda have to add the remote files to the
local eclipse project).
Do any modifications on the target system for my convinence eg. Adding an FTP server.
Thanks
I managed to get what I want by creating what you call a Symbolic Link in c:\wamp\www (using WAMP) folder which is also my eclipse workspace, for the network shared project I wanted to import into Eclipse. To do this open an elevated command prompt and run this command
mklink /d projectname \\network_shared_folder
/d option creates a directory symbolic link. Now, the network project will be available as a local project on the web root which can be easily imported into Eclipse (or any other IDE)
Hope this comes in handy for someone who stumbles upon this problem. Now I can get content assist for any file in the project.
Thanks.
In the project explorer if not exist create a new project then:
1) right-click the project and select New > Folder
2) Specify a name for the folder
3) click on Advanced
4) Check Link to alternate location (Linked Folder)
5) Enter a file system path, or click Browse to select a folder in the file system.
6) Click Finish
Check here for more Creating Linked Resources on Eclipse
After hours of searching, I share the solution finally found: symbolic links are not usable if the project is managed via git.
Another solution is to use the fileSync plug-in (http://marketplace.eclipse.org/content/filesync) to automatically copy folders from the source project to user projects.

PHP Project Organisation and Deployment (FuelPHP)

This project is using the FuelPHP framework but the question is around organisation of files.
My file structure is as follows:
/fuel
/app
/assets
...
/public
I current have assets.mydomain.com pointing to /fuel/app/assets but where would I place user content files such as profile pictures, etc.
In terms of deployment, I have never deployed a project like this before and I need some way of automating it, (using rsync or something). I wondered if anyone could recommend a way I can do this without wiping user files.
As suggested, I kept the assets directory under public. User content is stored in the media directory:
/public
/assets
/media
Regarding deployment, I use a simple git workflow: I have a bare git repo on my target server and a post-receive hook that checkout the branch in the working directory under my docroot.
To deploy, I just push from my local repo to the bare remote.
More details here: http://toroid.org/ams/git-website-howto

How to avoid crashing your web app during replacing a file?

Let's say you have a big web app with large visits, but you don't want your app to crash & you don't want people to see the php or mysql errors that happens during replacing files using FTP, How to avoid that? How to just execute the old version of file until the replacing is done?
Thanks
you can follow at least one of this 2 rules:
to use accelerators (like APC) with turned off mtime checking. so until you clear cache manually - old versions will be used from memory
to use virtualhost symlinked to directory with your project: let's examine you store yout project at /home/project/www. and /home/project/public_html is your real webroot and symlinked to www. so - create /home/project/www2, checkout files there, setup and do whatever you want. after this - just change symlink.
I use git to upload my changes to a staging website on the same server, after testing I then push it to the production website. None of the files are changed until they are all received. On the plus side, it only sends the changes compressed, so I don't even have to send an entire file.
The staging area isn't required. I work with a lot of servers and sometimes some of the specific configurations on that server (mostly just find that an extension isn't installed)/
I'm sure you can do the same with another version control system. You need to be careful though. The tutorial I linked specifically stores the git information OUTSIDE the document root. Otherwise someone can just clone all the source code for your website.
If you like SVN, the .svn being in every directory can be a little annoying. Make sure that people can't download what they shouldn't be able to.
Deploy your app into the temporary directory. Then after you done, just rename the original app directory to app.old and the directory where you deployed your files into app
Note this should work okay in Unix environments. Also this will only work if all of the above directories are on the same file systems. In rare case users might see 404 error if they happen to access the app after your renamed the original app into .old and before you renamed temp dir into the original app directory.

Categories