external libraries in codeigniter - codeigniter

I have my directory structure set up as follows:
application
controllers
models
libraries
views
etc
library
codeigniter_1_7_2
codeigniter_1_7_1
public_html
images
scripts
This has worked well for me, and I like having the codeigniter "master" files off in their own library. A quick switch in the index.php file and I can swap between different versions.
One thing that I WANT to do is when using something from Zend (like the search/lucene class) is to put the Zend directory under the main "library" folder. It's recommended that it go in my application/libraries folder, but then often when I search for a piece of code in my application I get a huge set of results from the large Zend library that I have to scroll through. It also really doesn't belong there given how I've set up my directory structure.
My problem is that if I try and put zend in the /library folder, I have to use php's require_once (I assume) and then I get permission errors.
If the zend library is at /application/libraries/Zend, this works:
$this->load->library('zend', 'Zend/Search/Lucene');
$this->load->library('zend');
$this->zend->load('Zend/Search/Lucene');
If the zend library is at /library/Zend this does NOT work:
require_once('../library/Zend');
The directory route is correct there, I just get a "permission denied" error.
Has someone else had this problem or figured out a nice easy way to set up their external libraries similar to how I'd like to do it?

Related

Apache treatment of symbolic links under Windows

Does +FollowSymLinks work with Windows shortcuts? It seems it is completely ignored by Apache under Windows 10.
The importance of this is that, some web frameworks, like Laravel, use this directive to access storage folder (or any other folder outside the public directory) throughout symbolic links. Then, these features are simply ignored in Apache under Windows.
Could anyone, more experienced than I, conform or explain me that? Could you also tell me if there is any workaround?
Thanks for any help!
Shortcuts aren't symbolic links, that's not the same. In order to put a filesystem reference to a file or directory on Windows, you need to use mklink command in either CMD or PS console.
As for Laravel, it ships with no outside dependencies, meaning everything Laravel needs to work aside from PHP itself should be located in the served directory, minding the path in configs. As far as I know, Laravel doesn't use any kind of symbolic links as it is platform-independent, meaning that as long as you have PHP properly configured and compiled with needed extensions, it will work anywhere. It even ships with a default .htaccess used for routing inside /public directory, at least in Laravel 8.
The way Laravel files reference each other is rather simple, check relative paths. Mind they are also implemented as a part of filesystem in any Windows or *nix systems and behave similarly if not identically.
I propose to store the project as is in the config-defined directory and work on your code from there.

deploying an open source code igniter application

If i've built a web app using code igniter, what's the proper way to deploy it? Should my install only include my files, or do I also package all the codeigniter code with it?
I'm just entering into the world of open source so I'm not so sure what protocol is.
Thanks.
This is a good question and I've seen it done both ways. There's definitely reasons Not to include the CI files. Like any potential in the future license changes. And it seems like with the projects that are shared by more experienced developers that is how they do it.
Because if you are sharing your project for other CI developers, then the reality is they will not use the copy of CI you include - they will fold your files into their version of CI. So including JUST the files needed for your app - actually makes much it easier. Its certainly what I would prefer. Just keep the standard application folder structure: config controllers models etc. but only include the folders that you have files for. And make it clear what version of CI you have tested it on. If you can say it will work on the release version (not the beta) then people on PHP 5.2 will know they can use it.
Of course you need to include all the CodeIgniter files, or else how would it run?
Most people tend to rename the application and system files and place them outside of the web root for security reasons. "After moving them, open your main index.php file and set the $system_folder and $application_folder variables, preferably with a full path, e.g. '/www/MyUser/system'".

Move source code files to CodeIgniter folders

I am starting to work on some incomplete stuff in codeigniter. I had to install codeigniter on my machine. I have the source code files from the previous work, however I am confused how to move these files to CodeIgniter folder to access them as usual and start working on them.
I am not sure which files go to which folder in the CodeIgniter Folders available when downloaded.
Download and install Codeigniter on your machine first. Check out in which folders the controllers/models/views/configs reside.
Then you will have an idea which files reside where, if you still have some problems take a peek in the documentation.
CodeIgniter have and system a application folder.
I'd recommend a new download.
I doubt some change was made on system folder, so I think you can ignore it from your project and use the new downloaded one
The project is on the application and there you have some folders, as mentioned by gopi1410, that you need to take care, maybe there are libraries, models, controllers, configurations files, autoload, etc.
And tell us what it the version of you application. If it is a old version, there will be some problem using the new version system folder.

Modular Extensions CI anchors to assets

So, I'm making a CMS at the mo, and using the modular extensions HMVC CI 2.0. It's lovely. I'm wondering the correct method for keeping my assets (js, css, img) related to a module within the module directory.
The problem being, how do I link to these assets? Let's say I'm using a template engine and passing the js files to load for a specific page:
$js[] = 'assets/js/my_js.js';
I suppose I'm asking this all wrong, but is there an easy way to link using the current module's directory?
Thanks in advance.
There's nothing currently built in to CI or HMVC for this.
I prefer not to reference files that are allowed direct access, like images/js/css, from within the application directory. Mainly because:
I don't want anyone to know what the guts of my app look like. By referencing files from directly within a module, you expose your application's directory structure.
I would never do this if I weren't using HMVC
You must now allow direct access to (certain) directories within the application via .htaccess. For security reasons, I prefer to simply disallow the entire thing.
I understand the desire to be as modular as possible, but to me it's not worth this hassle. I prefer to keep a separate directory in a public folder called "modules" (duplicating my application/modules structure), that has nothing but "assets" (css, js, images...).
I'd offer some code but I have no clue how you are adding js/css to your views - it's probably much different than the way I do it. It would be easy enough to write a function to detect the current module, controller, or method and change the asset folder automatically, but this may interfere with other shared assets. I'd suggest writing an entirely separate function for loading assets from modules.

Linking files one solution to another solution is not working-- ASp.net MVC3

I am working on ASP.MVC3 project. I created a base project where I will have all common files / pages like Master Page, Global.asax, Web.Config, Script files, CSS files, and images. And I have another solution which will contain module related stuff and I am linking common files / pages from first solution with “Add As Link” (Add  Existing Item  Add As Link ) option (I am working with VS.net 2010 IDE).
After linking all the files are coming into second solution and looking fine.
But when I run, the application is not running. Getting the message enable debut which already there.
when i clilck OK i am getting the error “the operation could not be completed. Unexpected error” (i think its expecting the physical file in the second solution location only).
After some R & D I placed the web config and global.asax directly (which is normal) in the second solution then the application started running. The same case for images / css / script files.
Please let us know the issue what we are doing wrong or is there any other way to share/link files from another solution.
Thanks in Advance.
You're probably better off doing it the other way around - create a website project and link your libraries / base classes to your project by adding a reference to them. This way you add all your images, css files etc direct into the website.
That's the more usual way of doing it in my experience, hope it helps.
The reason it doesn't work is because the linked files aren't copied to your working directory. To make your solution work you simply publish it to some other folder and it would re-create the site with copies of all linked files. There's no need to re-organize your solution as it would deploy all linked files once you publish it.

Resources