How to access the URI in autoload.php file - codeigniter

How to access the file name and function name present in the URL in autoload.php file of codeigniter.
I can access the file name but how to access the function name ?
Only the file name is stored in the session?

Related

Laravel App Not Loading CSS From Public Installation Not In public_html

I've installed a pre-made Laravel app and followed the documentation to extract it to the public root except in the documentation they are installing it into public_html, but I have it in a subdomain in a folder named "test" which is on the same level as public_html.
All the CSS and JS should be loading from the public subdirectory, but they try to look for it in the main root folder.
For example, this file returns a 404 error:
https://test.mydomain.com/css/style.css
The file is actually at this location:
https://test.mydomain.com/public/css/style.css
The absolute path of the file is:
/home/mydomain/test/public/css/style.css
Instead of:
/home/mydomain/public_html/public/css/style.css
What environment or config file isn't set correctly and how do I set it to use the correct directory?
UPDATE
Changing the ASSET_URL to "public" fixed the first issue, but now the same thing is happening with the admin.
The app tries to load the dashboard with this URL:
https://test.mydomain.com/admin/dashboard
The page loads all the assets normally when I remove the word "admin" from the URL:
https://test.mydomain.com/dashboard
But this doesn't work for all the pages.
You can try to put public directory path in below given conflagration file.
Config File Path : config/app.php (asset_url)
'asset_url' => env('ASSET_URL', 'https://test.mydomain.com/public/')

Laravel path from Controller to a file

I am trying to implement payment by card in a laravel project. For this i neeed to make a link in Controller to a certificat file.
I put the file in public/files and i made a variable like this
$x509FilePath = '/files/public.cer';
When i'm trying to encrypt an object using this file i get the error
Error while loading X509 public key certificate! Reason:error:02001002:system library:fopen:No such file or directory
error:2006D080:BIO routines:BIO_new_file:no such file
error:02001002:system library:fopen:No such file or directory
error:2006D080:BIO routines:BIO_new_file:no such file
Can anyone help me? Thanks alot!
I think you have to reference the file path using the helper public_path()
Try using:
$x509FilePath = public_path('/files/public.cer');

Upload files in storage directory in laravel can't write image to data path

I am trying to upload in laravel with intervention image plugin
But get this error. sorry 4 bad english
Can't write image data to path
(E:\xampp\htdocs\my-project\storage\app/medicines/thumbs/medicines/MEmheIamxDfu8ePa1h5mtovKFzY0POJtfGW8BLYZ.jpeg)
if($request->hasFile('photo')) {
$photo = $request->file('photo');
$image = $photo->store('medicines');
$path = storage_path('app/') .$image ;
Image::make($path)->resize(75,75)->save(storage_path('app/medicines/thumbs/'.$image,50));
Error message mean that web server user have no permission to write in that path.
So to fix it:
Change your directory upload path to app/public or app/storage directory
If you want to store in app/storage you can follow Laravel doc
Allow permission to web server(Apache user, etc.) to the path above

How to use SimplePie with Laravel

I am using Laravel 5.2. I need to get RSS feeds using SimplePie, so I install the library through composer.json and now my vendor folder contains simplepie but when i run the following code this error shows:
ErrorException in SimplePie.php line 1379: ./cache is not writeable.
Make sure you've set the correct relative or absolute path, and that
the location is server-writable.
My code in route:
Route::get('feed', function () {
$feed = new SimplePie();
$feed->set_feed_url(array(
'http://www.thenews.com.pk/rss/2/16' //it has no images
));
$feed->init();
$itemCount=$feed->get_item_quantity();
return $itemCount;
});
Create a writeable cache folder for simplepie in the /storage/ folder (I called mine simplepie_cache).
Set the path in your feed object:
$feed->set_cache_location(storage_path() . '/simplepie_cache');
That should do the trick.
check what is saying ./cache is not writeable can't write to cache folder check permissions to this folder or try a L5 wrapper for SimplePie https://github.com/willvincent/feeds

How to open a pdf file which is in views or controller folder in ci?

i have a pdf file in view folder and controller folder by the link i need to access it how to do this i have tried with following by am getting error like
Access forbidden!
$path=base_url()."application/views/users/sample_pdf_report.pdf";
$path2="C:\xampp\htdocs\vacationgod\application\views\users\sample_pdf_report.pdf"
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED
echo ("<a href='$path2'>Download Your PDF</a>");
i have tried both $path and $path2
You probably have a .htaccess file forbidding people to access files in those folders.
You should create a res folder in your site root path and place your pdf file in that folder and link the file from there..
Happy coding :)

Resources