Symfony 2: How and where to store runtime settings file - php

I am working on a Symfony 2 WebApp that uses the PayPal Rest API to create and accept PayPal payments.
To be able to redirect each user to a PayPal page in his language, one has to create an Experience Profile for each language/locale.
Each Experience Profile has to be created only once. For example once a profile for US locale has been create, this profile can be re-used for every customer using the same locale:
Customer enters his address and contry XY on my page
My page checks if profile for XY locale exists
Create new profile for XY locale and store it OR re-use existing one
Each profile has a unique ID. Thus I am looking for a method to store Locale/ID pairs. A simple solution would be a JSON file. But where to store this file within the Symfony structure?
Profiles are created on the fly when ever a user from a new country places a payment. Thus this data is created during runtime and because of this it does not belong into the standard config dirs of Symfony I think. I do not even know if these folders should accessible/writeable by my code.
So: What is the right place to store such a file.
EDIT:
As #JimL pointed out in the comments it would of course be possible to store the data in the DB. However the Payment Bundle I am working on, should be used in different projects and thus be as separated from the rest of the project as possible.
The goal here is, to store the data in a file, not in the DB. Of course the DB is much more efficient but in this special case a simple file will be sufficient.
The question is: Where to store this file? First idea is to use /MyBundle/Resources/config since this dir holds all other config files. But is this the right place for files that change at run time as well?

Standard Symfony directory structure for 3.x is:
app/
The application configuration, templates and translations.
bin/
Executable files (e.g. bin/console).
src/
The project's PHP code.
tests/
Automatic tests (e.g. Unit tests).
Standard Directory Structure is:
var/
Generated files (cache, logs, etc.).
vendor/
The third-party dependencies.
web/
The web root directory.
You can put it in the standard var directory under your custom directory. Remember about permissions.
More general info on var directory:
http://www.linfo.org/var.html

Related

logic behind websites like dropbox,google drive

I am creating website which is similar to dropbox. My logic behind the project is that I am going to create 1 table which includes username and pass and unique id.
Then I will create folder with name as that of the unique code and I will store that particular person file like video, mp3, txt in that particular folder. Now my question is how to restrict other users from entering into that folder(because I can access that folder by directly entering the url)?
Also suggest me if any other logic is more efficient.I am working on mini project.
I believe that Google Drive (and Dropbox probebly too), use https behind the scenes. In that case you simply need to make sure that your php/asp files make sure only the logged on user can access his/her files. It all depends on how your creating your cloud platform. You could also use scp, ssh, in that case your server automatically directs the client command to his/her own files.
You would need to create a controller that handles access to files. Do not direct link to the files, for example if you pass your arguments as /myFolder/myImg.jpg, then the controller would take the logedin user unique_id and the path as arguments, and then it would create a path it self.
2323-2332-a51df/myFolder/myImg.jpg
The idea is that the uniqueID will serve as base path, and your controller will handle all file access. This way you dont have to chmod 777 anything. Your controller will have access only to the folders you require and all will remain within your php settings. No need to worry about somebody trying to access any system folders.
Next to that you would just need to load the file contents and return it with the appropiate mime type.

How to use a loader script with PHP app?

So I have designed a PHP application that uses an oAuth2 API integration to create a unique interface for a CRM. App is working great on my server, and am ready to offer it to my clients.
My initial idea for expanding this was to create a unique subdomain for each of them on my server, create a new database, and install my application onto that subdomain. My application only has one hard-coded file with the database login details, the rest is stored on a database.
The problem I see with this is it is inefficient. I am essentially going be putting in the same files in many directories, which doesn't make a whole lot of sense. Plus updating it would be annoying.
Since everything is being hosted by me, it was suggested that I create a core folder with all of the files. Then I could use a loader script to read the database settings, and then use relative paths to access the core folder.
My issue is how would this work? Suppose my core domain is https://core.mydomain.com and my customer url is https://cus.mydomain.com. Customer logins through their url. Now a customer wants to access https://cus.mydomain.com/person.php. How would I make that work, considering that file is not located there (since it is in the core folder)? Would this require using custom htaccess?
If my current idea is wrong, what approach would you suggest? I am not married to this approach, and am looking for an efficient way of updating and managing the app. Thank you!
Use a symbolic link?
https://en.wikipedia.org/wiki/Ln_(Unix)
You can create a folder with all your static files in /var/www/core/ and create a symbolic link in each customers folder.
ln -s /var/www/core /var/www/customer001/core/
this way all modifications in /var/www/core/ will be available to all customers

How to make web installer for my Laravel application?

I know of #RachidLaasri/LaravelInstaller but it is rather a kind of different thing I want.
I want to do something like, go to a URL like localhost::8000/installer. Then, it will display a page for super admin registration, i.e., email, password, and username. Note: I want to eliminate the ability of making my superadmin app user going to the UsersTableSeeder to configure anything.
Then, when I click on install, it migrate my seeded classes. I currently watched the command line app but still can't really figure out how to go about this.
Any advice / tip will be appreciated.
Laravel Installer
add 2 router in your project.
http :
routes.php
routes2.php
---
view
application/
installation/
in first route you should take db name and more information you need from user. Save db name to .evn file.
After then you might create database using php codes, How to make db Pdo
and run \Artisan::call('migrate') in your Controller.
Rename route to installation-route using php rename method file. And rename route2 to route.
Have you tried this PHP Application Installer
This library can be used for PHP appplication configuration(database, admin credentials etc) using user interface.

Integrate ElFinder with existing permission system

Is there a way to integrate elfinder with my current user permissions system? I would need some kind of hook which would be triggered before e.g. a file gets deleted. There I should be able to abort the delete command and return some kind of response if the logged in user doesn't have enough permissions.
Closest thing I found until now is this: Connector Configuration options - Bind
But it doesn't look like I'm able to abort the current action there....
It all depends on the way you implemented the server-side connector.
For example, I have a custom connector for PHP backend which saves and returns the files / folders based on a database table. This way, I can set the read and write options for each file / folder (check the Client-Server API docs).
To answer your question, you'll need to tweak the server side connector to set the read and write attributes, like stated in this wiki page.

Link files from file system repository to courses in moodle

I have to create about 2000 course with 5000 documents in Moodle 2.4. I have used Bulk category upload and bulk course upload to create the courses.
As file management in Moodle 2.0 has changed and files cannot be placed directly to moodle appdata folder. I created file system repository in Moodle Appdata and uploaded all files with their course id (id from DB table after creating courses) as directory name.
After enabling file system repository i can now see files in file picker. Now i use file picker to link those files to their courses manually. Another option is drag and drop files to their courses. But it is time consuming and it may lead to human error as every course has to be opened and above options has to be done.
I gone through mdl_files table to link files to their courses but the contents are encrypted and i cannot directly link files to their courses using DB as of in course file area in Moodle 1.9. I wrote script using Moodle File API but that could also be done in course only.
Is there any way that linking of those files can be done through script or database to their corresponding courses in bulk.
Thanks in advance
I'm not aware of a solution that doesn't involve writing some code.
However, you could take a look at the code in course/dnduploadlib.php, as that should be possible to adapt this to loop through all the files in a given directory on the server and convert them into resources.
If you created a draft file area (using the files API), you could then use an adjusted version of the 'handle_file_upload' function (and the functions it calls) to do this.

Categories