phpspreadsheet which is installed on subdirectory by composer, not working - php

I installed phpspreadsheet on my subdirectory banana(OMG.com/fruits/banana).
And tried to open its sample page.(banana/vendor/phpoffice/phpspreadsheet/samples/index.php)
But it didn't work.
So I followed source, and changed css and js path on Header.php like this.
From <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css"/>
To <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/>
Then the sample page (samples/index.php) shows correctly. So I clicked its sample menu. But it didn't work again. Error code was 404. I opened sample/index.php and observed sample menu link. The link was this.
OMG.com/Autofilter/10_Autofilter.php
But 10_Autofilter.php was not in there. it was in here.
OMG.com/fruits/banana/vendor/phpoffice/phpspreadsheet/samples/Autofilter/10_Autofilter.php
I found the reason is path. But I didn't know how to solve. I thought the easiest way is install phpspreadsheet by composer on root directory. But I thought again and it's not gonna success. because if I install phpspreadsheet on root directory, the sample pages will be on here.
OMG.com/vendor/phpoffice/phpspreadsheet/samples/Autofilter/10_Autofilter.php
But the link was like this.
OMG.com/Autofilter/10_Autofilter.php
Maybe this can be easy fundamental problem. But I don't know how.
Help...
PS. I installed phpspreadsheet on here.
OMG.com/fruits/banana> composer require phpoffice/phpspreadsheet

PHPSpreadsheet is a library, intended to be used by your programs, and not directly accessible through a web interface.... and the examples are written to be run from the command line (if you want to run them).
You need to create a script in your normal home directory that includes the vendor autoloader, and then the classes in PHPSpreadsheet will be accessible to your script

Related

Laravel cannot find stylesheets and nor can I

So I'm very new to Laravel and I'm following a tutorial to use the authentication feature. This works fine, however it is unable to find my scripts and stylesheets. I haven't made any new ones nor have I touched the stylesheet link in app.blade.php, so I have no clue why it is throwing this error.
Code:
<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet">
Error:
GET http://localhost:8000/css/app.css net::ERR_ABORTED 404 (Not Found)
When I go to locahost/css/app.css I get a 404 error. The same error is occurring with app.js. I haven't changed anything about the file structure and it was all generated with composer create-project laravel/laravel
Thanks.
Laravel doesn't include any CSS files by default. You need to create one yourself and put it to /public/ directory, so in your case that would be /public/css/app.css.
Does localhost point to public in your project? Usually you would have to open http://localhost/public
Per default, URL::asset('css/app.css') expects a css file at /public/css/app.css -- for your setup (serving throught php artisan serve, I suppose?), that would be http://localhost:8000/public/css/app.css.
Anyway: If there is no stylesheet, just create one. There is tons of ways how to do it, depending on your needs. Creating one manually for one, but for complex sites think about using laravel mix for compilation. Or anything other way!
Make sure your style exists at public/css directory, then try this code:
<link rel="stylesheet" href="{{asset('css/app.css')}} type="text/css"/>
if the file doesn't exist, create that and try again.
I hope this can help you.

Laravel does not find css file : GET http://localhost:8000/cssFile net::ERR_ABORTED

My laravel project does not find any of the css files of any of the pages. It shows up with the error,
GET http://localhost:8000/dashboard.css net::ERR_ABORTED
Did not find too many of the similar questions but tried the some solutions that I have found but obviously those did not help, otherwise I would not be asking again.
I`m using a Ubuntu PC.
Here are everything that I have tried.
Checked file permissions, all the files have all read, write and execution privileges.
Tried restarting the localhost many times.
Tried using the asset() function, <link rel="stylesheet" type="text/css" href="{{asset('dashboard.css')}}">
Tried using absolute path though I have the css files in the same directory as the blade.php files.
None of the above mentioned ways fixed it. Some clue would help me a lot. Thank you.
The CSS files need to be in the public folder, or a subfolder of public, not the view folder where the blade php files are. public is where you want to put any javascript files, css files, images, or whatever, and the root of the public folder becomes the root of your website when it's running.

CakePHP 3.4 load jQuery to layout

I started using libraries like jQuery or Twitter Bootstrap with composer. Now I want to load the jquery.min.js from /vendor/components/jquery/ into my /src/Template/Layout/default.ctp.
How can I do that?
Because using a normal uri doesn't work:
<script type="text/javascript" src="/vendor/components/jquery/jquery.min.js"></script>
Cake doesn't interpret the file as a file. It looks for a Controller:
Error: VendorController could not be found.
How can I load the JS-file properly?
This question is perhaps a little broad, but you probably want to look into using something like Gulp or Webpack to build your assets from the Composer files to your app's webroot. These will also enable you to concatenate and minimise all your JS/CSS assets to improve performance. Although personally I'd probably use a CDN to deliver a library like jQuery as it is so commonly used on the web that you can benefit from cross-site caching.
The reason why you are getting an error like "Error: VendorController could not be found." is because Cake can't find the 'vendor' directory inside 'webroot' so is looking for a Controller instead due to the way it handles magic routes (this bit in the routes.php file $routes->fallbacks('DashedRoute');).
If you don't want to use a tool like Gulp or Webpack you could symlink the relevant files in your webroot folder, but personally I'd use my initial suggestions as these will give you many other benefits. If you do symlink just make sure you don't symlink the entire vendor directory as you don't want to expose all the code in there.
You should place all your js in /webroot/js folder. You can use it inline by using:
echo $this->Html->script('jquery.min');
this would load : <script src="/js/jquery.min.js"></script>

Compile some SCSS files to CSS (I am a beginner with Sass)

I am currently new to Sass and my friend gave me a project that contained a Material Design 'template', that he made.
Unfortunately there is no .css file that got all the stylesheets in it.
There are a couple of .scss files though but I do not really know how to compile them all to a .css file.
I figured out that I could use 'gulp', but when I add all the files in the gulpfile.js to be compiled, it doesn't work.
I am wondering if someone could help me over Skype or something that I could share my screen and that someone could fix this for me.
Here you can see that there are many scss files and there are two folders with components and mixins.
Some of the scss files also contain '#import' lines, but I do not know if I have to add those files in the gulpfile.
Here is a screenshot of the components folder:
I could not post a 3rd screenshot because of my reputation but the mixins folder contains the following files:
- _alerts.scss
- _buttons.scss
- _md-shadow.scss
- _placeholder.scss
I hope that someone could help me with this!
PS: It is in a Laravel project!
Thank you so much!
Kind regards,
smke
You can use Scout-App easily with sass and you should create a scss file without undescore (_) to import other scss file with underscore. In Scout-App you have to select input folder that include directory with scss files and select output folder where you want to be css file export.
Luckily, there's a SCSS to CSS converter online. Just go to http://www.cssportal.com/scss-to-css/ and copy the paste the code and press Compile. The CSS code will display below the button for you to copy and paste.

Use bootstrap with composer

I'm a web newbie programmer,
I'm trying to learn from home to make my own web.
I have notions of php, html, js and css.
But I've found something that is not how to solve.
I'm trying to use Composer to manage Bootstrap. I installed Composer and I have run this line of code
composer require twbs/bootstrap
that has dropped a folder with files.
I do not understand is how I make html links to find the js and css files, you should do indicating the full path?
vendor / twbs / bootstrap / dist / js / bootstrap.js
Excuse me if the question is stupid but I do not know how I should continue.
Amd excuse my English, I'm learning too but by now I use google translate
You could use a post update command in the composer.json file:
"scripts": {
"post-update-cmd": [
"rm -rf public/bootstrap",
"cp -R vendor/twbs/bootstrap/dist public/bootstrap"
]
}
And then just include the javascript- and css-files like this:
<script type="text/javascript" src="{{ ROOT_URL }}bootstrap/js/bootstrap.min.js"></script>
<link href="{{ ROOT_URL }}bootstrap/css/bootstrap.min.css" rel="stylesheet">
Yes, Composer downloads the dependencies by default into the vendor folder. So Bootstrap will also land in the vendor folder, which is not the correct place to reference it or include it.
composer require twbs/bootstrap ➔ vendor/twbs/bootstrap/dist/js/bootstrap.js
Your next step would be to write a little helper script to copy the Boostrap files you need, into your public/assets folder. You could copy the complete dist folder including sub-folders (vendor\twbs\bootstrap\dist) into public or public\assets.
Please overwrite existing files, e.g. if a file exists remove it, then copy it. This allows to easily update the files, when you need to update the Bootstrap vendor package again.
Of course, you could also just copy the files manually or create a symlink. It depends.
That gives you the following directory structure:
public
\- assets
|- css
|- js
\- fonts
\- index.html
When the Boostrap assets are copied you can start to include them, in your index.html or template (assets\js\bootstrap.min.js, etc.).
Referencing: https://stackoverflow.com/a/34423601/1163786 which shows also other solutions to this problem, e.g. fxp/composer-asset-plugin, bower, grunt.
Unless you need customization inside bootstrap (e.g. building scss), the most simple solution is relying on a CDN (as a bonus, you get super-fast caching of assets)
So, simply call your assets like so:
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="//code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
Composer is a super-excellent tool for backend dependencies, but not the best one for frontend.
If you want to have the files in your server, and you don't want to use npm, grunt or another frontend library manager, you can simply download the files listed in Massimiliano's answer and put them inside your js/css folders:
First download these files (updated to the most recent Bootstrap 3 version):
http://netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
http://code.jquery.com/jquery-2.2.4.min.js
http://netdna.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
And put them in these folders (starting from the root of your project):
public/css/bootstrap.min.css
public/js/jquery-2.2.4.min.js
public/js/bootstrap.min.js
Now, you want to be able to call them in the blade templates for your views. It's simple: just add <link> and <script> tags as normal for any css/js file, adding the following to your blade template:
<link href="{{ url('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" />
<script src="{{ url('js/jquery-2.2.4.min.js')}}"></script>
<script src="{{ url('js/bootstrap.min.js')}}"></script>
P.s.: if you see the console, it shows something as the following error message:
Source map error: request failed with status 404
Resource URL: http://localhost:8000/css/bootstrap.min.css
Source Map URL: bootstrap.min.css.map
This will not affect the style of your page, and you can simply ignore this message, or remove a line from the bootstrap file as the answers to this question suggest. This answer explain a bit more.

Categories