How to change Controllers/Models source directory in CodeIgniter - codeigniter

I need to load controllers and models from a different folder than the default one. I am using a Linux system.
I am building a simple CI application for some people, for use on a shared hosting I own. But I want to give them access only to /views folder and some /config files. And this is why I need to store the controllers and models in a different folder on the same level as /public_html folder or maybe somewhere in the linux system.
I consider this would be a better solution than encoding files

CodeIgniter permits you to organize your controllers,views and config files into sub-folders. As far as I know it doesn't permit it for models (at least documentation doesn't mention it, I've not tried myself).
As your are in a Linux system, you can create a symbolic link to reference to another directory in the filesystem.
So you can create the directories:
application/config/public
application/controllers/public
application/views/public
And then create in your /public_html symbolic links ponting to these directories:
/public_html/config -> application/config/public
/public_html/controllers -> application/controllers/public
/public_html/views ->application/views/public
When your customers upload files to /public_html/config, they will be also available in application/config/public. The same applies for /public_html/controllers and /public_html/views.
The command syntaxis to creates symlinks is
# ln -s target name
i.e:
# ln -s application/config/public /public_html/config
If you don't have console access to your hosting you can create the links using the PHP function symlink() .
To load a view/config/controller from a subfolder you only have tu prepend the directory name in the $this->load->...() function call. i.e:
$this->load->view('public/my_view);
Check CI documentation for more info about organizing your files into sub-folders.

Related

Archive multiple folders under a single folder using Ansible

I'm using the below ansible-playbook code to archive multiple folders under IBM folder.
Below is my absolute path Directory structure:
/app
|-- /IBM
|--/test
|--/log
|--/common
|--/api
|--/<unknown folders>
The number of folders and files under IBM folder is unknown hence it seems impossible to specify all the files / folders under IBM under exclude_path attribute.
I wish to build an archive (gz) that has only IBM folder containing only two folders i.e common and api folders while ignoring the rest of the folders and files.
Thus, I wrote the below playbook:
- name: Creating the archive
archive:
path:
- /was/IBM/common
- /was/IBM/api
dest: /var/backup/mysetup.tar.gz
exclude_path:
- /was/IBM/common/log
- /was/IBM/api/tmp
format: gz
This gives me the archive file mysetup.tar.gz.
I want the mysetup.tar.gz file to have a folder called IBM which should have the two folders common and api. Thus, I'm expecting the below in the mysetup.tar.gz no matter what other files are under the IBM folder.
IBM
|--/common
|--/api
But, the mysetup.tar.gz does not have IBM folder but has common and api folders.
I was not specific hence my question did not get answered here: How to archive multiple folders under one folder using Ansible
Can you please guide me as to how I can get the archive to have both the folders inside the IBM folder inside the mysetup.tar.gz?
Requirement you have can't be achieved straight using archive module. Two specific reasons are listed below:
If you specify the path say /app/IBM then the content of the zip file will have the path after IBM something like common/, api/. To get IBM as a root directory inside the tar.gz file, you need to specify path as /app. This brings to the next point about the usage of exclude_path.
exclude_path doesn't work as you would expect. Say, if the path is define as /app and you want to exclude /app/IBM/test, this wouldn't work. exclude_path works only with direct sub folder/file of a defined path (with wildcard) which means that exclusion of /app/IBM/test would work if path defined as /app/IBM/* but that is not what is expected and brings back the previous point. There is already an issue reported on this topic.
So you probably better off using regular tar command using command/shell module.

Laravel Spark is not displaying images that are stored in the /storage/app/public/profiles/ directory

The default for uploaded images appears to be /storage/app/public/profiles/, but the frontend generated URL of /storage/profiles/image isn't being found.
I tried to find any sort of routing for that directory and haven't been able to do so. Any help would be appreciated.
You must link to the storage directory. From the documentation:
Once Spark is installed, you should link the public/storage directory to your storage/app/public directory. Otherwise, user profile photos stored on the local disk will not be available
And the relevant code:
ln -s /path/to/storage/app/public /path/to/public/storage
Just delete the storage folder inside public folder and run the command using absolute paths(from root folder).

What is a usual workflow for dealing with shared files with capistrano?

My .csv recreates on every release, and, as I understand, to keep its data unchanged between deploys I need to put it in /shared directory and simlink to it from my deploy.rb.
Is this the right route? (I have this question because I don't seem to find much info on how to do this with respect to, eg, databases, for some reason. /shared directory is mostly used for .conf files and paperclip-like directories).
When using capistrano, your application code will be "uploaded" to some directory on the server. Capistrano uses this structure:
/path_to_folder:
current - symlink to the directory with the current release
releases - contains all kept releases
shared - files that should persist between releases
So to your question - copy the .csv file somewhere into "shared" directory and then in the config/deploy.rb add this:
namespace :deploy do
task :create_symlinks do
run "ln -s #{shared_path}/something.csv #{latest_release}/db/something.csv"
end
end
after 'deploy:update_code', 'deploy:create_symlinks'
Replace "something" with the file name that you copied. You can also put the csv file into some directory under "shared" if you want to, I'd use "db" in this case. If you do so, don't forget to update path in the symlink.

Symlink not working when pointing one subfolder to a sibling subfolder

Trying to create a symlink in my hostgator shared hosting account via Jailshell 4.1 and my Mac's Terminal as a test before applying the symlinks to a larger project.
When I try the following it doesn't seem to work:
ln -s public_html/y public_html/x
As I get the following response:
ln: creating symbolic link `public_html/x/y': Permission denied
I am simply trying to set it up so that going to public_html/x will instead take me to public_html/y. My ultimate goal is to later configure many wordpress sites to share a single set of core files without sharing databases, as described here:
http://jason.pureconcepts.net/2012/08/wordpress-multitenancy/
http://jason.pureconcepts.net/2013/04/updated-wordpress-multitenancy/
Edit: Both folders /x and /y already exist, containing a simple index file in each.

How do I set up Code Igniter if my public html folder is a soft link?

I am setting up Code Igniter. My public html folder is a soft link to another folder on my server.
Hence, my directory structure looks like
README errors.txt license.txt system
application html user_guide
where html is a soft link to another folder /var/www/myPublicHTML/. html contains my index.php file.
Code Igniter currently issues this error.
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
However, I did specify this in my index.php file within the html soft link / folder.
$system_path = '../system';
$application_folder = '../application';
Why is this error still surfacing? I feel that it may be a soft link issue. Thank you.
The directory that the system symlink points to should permit access to all users. The webserver is probably attempting to access the system directory but doesn't have the proper clearance to do so (Note that the webserver doesn't use your user credentials to do its work).
If the system symlink points to /var/www/frameworks/CodeIgniter/2.x.x/system you should see to it that /var/www/frameworks/CodeIgniter/2.x.x/system is accessible to all users in order to allow the webserver to access that directory as well.
Running chmod 755 -R /var/www/frameworks/CodeIgniter/2.x.x/system should grant read and execute access to ALL users (and full access to yourself). Needless to say that you should enter the path to your system directory in the above command ;).
It should be work by default. if not write full path
$system_path = '/var/www/myPublicHTML/system';
$application_folder = '/var/www/myPublicHTML/application';
hi i got the similar problem after a little research i got to know that as i have installed xampp in different folder under c drive which is xampp1 thats why it was getting error so i supplied full path in config.php file which is
$system_path = 'C:/xampp1/htdocs/project/application/system';

Resources